# Photon,Relay Shield and Nextion Touchscreen Based Aquaponics/Indoor Greenhouse

**URL:** <https://community.particle.io/t/photon-relay-shield-and-nextion-touchscreen-based-aquaponics-indoor-greenhouse/18366>\
**Category:** Project Share\
**Created:** [December 17, 2015, 7:12pm UTC](https://community.particle.io/t/photon-relay-shield-and-nextion-touchscreen-based-aquaponics-indoor-greenhouse/18366 "2015-12-17T19:12:20Z")\
**Posts on this page:** 20\
**Page:** 1

<div class="post-metadata">

**Author:** ![Ali](https://avatars.discourse-cdn.com/v4/letter/a/8c91f0/32.png) [@Ali](https://community.particle.io/u/Ali)\
**Post date:** [December 17, 2015, 7:12pm UTC](https://community.particle.io/t/photon-relay-shield-and-nextion-touchscreen-based-aquaponics-indoor-greenhouse/18366/1 "2015-12-17T19:12:20Z")

</div>

Hello Everyone,

I am making an indoor greenhouse or maybe an aquaponics rig using the above components. I am currently taking introductory courses on programming so my knowledge is noobish. Any help willbe highly appreciated.

---

<div class="post-metadata">

**Author:** ![Ali](https://avatars.discourse-cdn.com/v4/letter/a/8c91f0/32.png) [@Ali](https://community.particle.io/u/Ali)\
**Post date:** [December 17, 2015, 7:15pm UTC](https://community.particle.io/t/photon-relay-shield-and-nextion-touchscreen-based-aquaponics-indoor-greenhouse/18366/2 "2015-12-17T19:15:48Z")

</div>

for starters on the Nextion CompPicture example i see dbSerialPrintln(“setup done”), shouldnt that print setup done on the screen?

```auto
{
    uint32_t number = 0;
    dbSerialPrintln("p0PopCallback");

    p0.getPic(&number);

    if (number == 1)
    {
        number = 2;    
    }
    else
    {
        number = 1;
    }
    
    p0.setPic(number);
}

void setup(void)
{
    nexInit();
    p0.attachPop(p0PopCallback);
    dbSerialPrintln("setup done");

```

---

<div class="post-metadata">

**Author:** ![ScruffR](https://sea2.discourse-cdn.com/flex026/user_avatar/community.particle.io/scruffr/32/6952_2.png) [@ScruffR](https://community.particle.io/u/ScruffR)\
**Post date:** [December 17, 2015, 10:03pm UTC](https://community.particle.io/t/photon-relay-shield-and-nextion-touchscreen-based-aquaponics-indoor-greenhouse/18366/3 "2015-12-17T22:03:54Z")

</div>

The important question is: What _screen_ are you refering to? (the Nextion display _screen_ or your computer _screen_)

Have you got a serial monitor on the computer that displays the debug messages sent from your Photon to the computer via USB?  
Since this would be the place where the messages are printed. _(provided I haven’t deactivated the debug output in the lib by default 😊)_

---

<div class="post-metadata">

**Author:** ![Ali](https://avatars.discourse-cdn.com/v4/letter/a/8c91f0/32.png) [@Ali](https://community.particle.io/u/Ali)\
**Post date:** [December 17, 2015, 10:21pm UTC](https://community.particle.io/t/photon-relay-shield-and-nextion-touchscreen-based-aquaponics-indoor-greenhouse/18366/4 "2015-12-17T22:21:05Z")

</div>

I was referring to the Nextion. But how do i set up my computer screen to display serial prints. I installed the CLI but could’nt figure out where to monitor serialPrintln from.

---

<div class="post-metadata">

**Author:** ![ScruffR](https://sea2.discourse-cdn.com/flex026/user_avatar/community.particle.io/scruffr/32/6952_2.png) [@ScruffR](https://community.particle.io/u/ScruffR)\
**Post date:** [December 18, 2015, 12:13am UTC](https://community.particle.io/t/photon-relay-shield-and-nextion-touchscreen-based-aquaponics-indoor-greenhouse/18366/5 "2015-12-18T00:13:58Z")

</div>

If you have CLI installed just run `particle serial monitor`

If you are on Windows, you’d also need to install the device drivers for USB Serial.  
See this post  
[[Particle Official] Windows 10 Full CLI and DFU Setup](https://community.particle.io/t/particle-official-windows-10-full-cli-and-dfu-setup/18309)

---

<div class="post-metadata">

**Author:** ![Ali](https://avatars.discourse-cdn.com/v4/letter/a/8c91f0/32.png) [@Ali](https://community.particle.io/u/Ali)\
**Post date:** [December 18, 2015, 1:49pm UTC](https://community.particle.io/t/photon-relay-shield-and-nextion-touchscreen-based-aquaponics-indoor-greenhouse/18366/6 "2015-12-18T13:49:05Z")

</div>

Thanks. I will start with getting my DHT 22 to print values on serial and then use COMPTEXT or WAVEFORM as examples to get the Nextion to show those values.

---

<div class="post-metadata">

**Author:** ![Ali](https://avatars.discourse-cdn.com/v4/letter/a/8c91f0/32.png) [@Ali](https://community.particle.io/u/Ali)\
**Post date:** [December 21, 2015, 5:12pm UTC](https://community.particle.io/t/photon-relay-shield-and-nextion-touchscreen-based-aquaponics-indoor-greenhouse/18366/7 "2015-12-21T17:12:12Z")

</div>

I tried getting a reading on the sensor using the simple example.ino on the serial monitor but all it says is press any key to start. Pressing any key has no effect.

---

<div class="post-metadata">

**Author:** ![ScruffR](https://sea2.discourse-cdn.com/flex026/user_avatar/community.particle.io/scruffr/32/6952_2.png) [@ScruffR](https://community.particle.io/u/ScruffR)\
**Post date:** [December 21, 2015, 5:24pm UTC](https://community.particle.io/t/photon-relay-shield-and-nextion-touchscreen-based-aquaponics-indoor-greenhouse/18366/8 "2015-12-21T17:24:50Z")

</div>

Where does the `example.ino` come from?

But I guess there is a `while (!Serial.available())` line. Just comment this out, then your code should run through.

---

<div class="post-metadata">

**Author:** ![Ali](https://avatars.discourse-cdn.com/v4/letter/a/8c91f0/32.png) [@Ali](https://community.particle.io/u/Ali)\
**Post date:** [December 21, 2015, 5:27pm UTC](https://community.particle.io/t/photon-relay-shield-and-nextion-touchscreen-based-aquaponics-indoor-greenhouse/18366/9 "2015-12-21T17:27:15Z")

</div>

````auto
 * VERSION: 0.3
 * PURPOSE: Example that uses DHT library with two sensors
 * LICENSE: GPL v3 (http://www.gnu.org/licenses/gpl.html)
 *
 * Example that start acquisition of DHT sensor and allows the
 * loop to continue until the acquisition has completed
 * It uses DHT.acquire and DHT.acquiring
 *
 * Change DHT_SAMPLE_TIME to vary the frequency of samples
 *
 * Scott Piette (Piette Technologies) scott.piette@gmail.com
 * January 2014 Original Spark Port
 * October 2014 Added support for DHT21/22 sensors
 * Improved timing, moved FP math out of ISR```

This one!! i will try commenting out the line.
````

---

<div class="post-metadata">

**Author:** ![Ali](https://avatars.discourse-cdn.com/v4/letter/a/8c91f0/32.png) [@Ali](https://community.particle.io/u/Ali)\
**Post date:** [December 21, 2015, 5:40pm UTC](https://community.particle.io/t/photon-relay-shield-and-nextion-touchscreen-based-aquaponics-indoor-greenhouse/18366/10 "2015-12-21T17:40:53Z")

</div>

works now!!

---

<div class="post-metadata">

**Author:** ![Ali](https://avatars.discourse-cdn.com/v4/letter/a/8c91f0/32.png) [@Ali](https://community.particle.io/u/Ali)\
**Post date:** [December 28, 2015, 10:26pm UTC](https://community.particle.io/t/photon-relay-shield-and-nextion-touchscreen-based-aquaponics-indoor-greenhouse/18366/11 "2015-12-28T22:26:38Z")

</div>

I am trying to monitor time and date over the internet. Using one of the examples i found on the library for using the time library. My question is how can i get publish to work with the function digitalClockDisplay and not have to publish both the events individually using the string.

```auto
void loop() {
    digitalClockDisplay();
    delay(5000); // wait one second between clock display
    Particle.publish("clock", "Time: " + String(Time.format(Time.now(), "%I:%M%p.")));
    delay(5000);
    Particle.publish("date", "Date: " + String(Time.format(Time.now(), "%x.")));
    delay(5000);
    Particle.publish("all",String(digitalClockDisplay()));
    
   
    
   
    
}

void digitalClockDisplay()
{
     Serial.println(Time.format(Time.now(), "%I:%M%p."));
     Serial.println(Time.format(Time.now(), "%x"));
  // digital clock display of the time

```

---

<div class="post-metadata">

**Author:** ![ScruffR](https://sea2.discourse-cdn.com/flex026/user_avatar/community.particle.io/scruffr/32/6952_2.png) [@ScruffR](https://community.particle.io/u/ScruffR)\
**Post date:** [December 28, 2015, 10:31pm UTC](https://community.particle.io/t/photon-relay-shield-and-nextion-touchscreen-based-aquaponics-indoor-greenhouse/18366/12 "2015-12-28T22:31:27Z")

</div>

Have you had a look at the docs about `Time.format()`?  
It can produce a combined datetime format.

It states two predefined combinded datetime formats and the option to create a custom format too

> [@](#):
>
> The formats available are:  
> TIME\_FORMAT\_DEFAULT  
> TIME\_FORMAT\_ISO8601\_FULL  
> custom format based on strftime()

Where [`strftime()`](http://www.cplusplus.com/reference/ctime/strftime/) refers to a standard C function that can be googled to really get into the depths of the formatting options.

Also `Particle.publish("all",String(digitalClockDisplay()));` won't work since your functino does not return anything "stringyfiable" 😉

---

<div class="post-metadata">

**Author:** ![Ali](https://avatars.discourse-cdn.com/v4/letter/a/8c91f0/32.png) [@Ali](https://community.particle.io/u/Ali)\
**Post date:** [December 28, 2015, 10:38pm UTC](https://community.particle.io/t/photon-relay-shield-and-nextion-touchscreen-based-aquaponics-indoor-greenhouse/18366/13 "2015-12-28T22:38:51Z")

</div>

This post has an example of using the time format. I have read it. I'm trying to format the string to show hh:mm:tt dd/mm/yyyy.

> [@String.format() (added in 0.4.6) does not compile \[SOLVED\]](https://community.particle.io/t/string-format-added-in-0-4-6-does-not-compile-solved/16145/3):
>
> This seems to work for me? [image]

---

<div class="post-metadata">

**Author:** ![ScruffR](https://sea2.discourse-cdn.com/flex026/user_avatar/community.particle.io/scruffr/32/6952_2.png) [@ScruffR](https://community.particle.io/u/ScruffR)\
**Post date:** [December 28, 2015, 10:48pm UTC](https://community.particle.io/t/photon-relay-shield-and-nextion-touchscreen-based-aquaponics-indoor-greenhouse/18366/14 "2015-12-28T22:48:42Z")

</div>

Following the link to `strftime()` you could either use the cryptic `"%X %x"` or the more elaborate and clearer `"%H:%M:%S %d/%m/%Y"`.

If I assume “hh:mm:tt” should rather be “hh:mm:ss”.

---

<div class="post-metadata">

**Author:** ![Ali](https://avatars.discourse-cdn.com/v4/letter/a/8c91f0/32.png) [@Ali](https://community.particle.io/u/Ali)\
**Post date:** [December 28, 2015, 10:49pm UTC](https://community.particle.io/t/photon-relay-shield-and-nextion-touchscreen-based-aquaponics-indoor-greenhouse/18366/15 "2015-12-28T22:49:42Z")

</div>

Im trying that now. tt was for AM/PM.

---

<div class="post-metadata">

**Author:** ![ScruffR](https://sea2.discourse-cdn.com/flex026/user_avatar/community.particle.io/scruffr/32/6952_2.png) [@ScruffR](https://community.particle.io/u/ScruffR)\
**Post date:** [December 28, 2015, 10:53pm UTC](https://community.particle.io/t/photon-relay-shield-and-nextion-touchscreen-based-aquaponics-indoor-greenhouse/18366/16 "2015-12-28T22:53:51Z")

</div>

In that case it would be "`%I:%M%p %d/%m/%Y"` (I don’t think there should be a colon between `mm` and `AM/PM`)

---

<div class="post-metadata">

**Author:** ![Ali](https://avatars.discourse-cdn.com/v4/letter/a/8c91f0/32.png) [@Ali](https://community.particle.io/u/Ali)\
**Post date:** [December 28, 2015, 11:13pm UTC](https://community.particle.io/t/photon-relay-shield-and-nextion-touchscreen-based-aquaponics-indoor-greenhouse/18366/17 "2015-12-28T23:13:07Z")

</div>

```auto
Particle.publish("All",(Time.format(Time.now(),"%I:%M%p %d/%m/%Y")));
delay(60000);

```

that works! But i cant help wondering if this is the simplest way of doing it. Or am i missing something out?

---

<div class="post-metadata">

**Author:** ![ScruffR](https://sea2.discourse-cdn.com/flex026/user_avatar/community.particle.io/scruffr/32/6952_2.png) [@ScruffR](https://community.particle.io/u/ScruffR)\
**Post date:** [December 29, 2015, 9:13am UTC](https://community.particle.io/t/photon-relay-shield-and-nextion-touchscreen-based-aquaponics-indoor-greenhouse/18366/18 "2015-12-29T09:13:21Z")

</div>

No the easiest way is

```cpp
void setup()
{
  ...
  Time.setFormat("%I:%M%p %d/%m/%Y");
}

void loop
{
  Particle.publish("All", Time.format());
  delay(60000);
}

```

Another easy way for custom formatting without setting the default format in `setup()`

```cpp
  Particle.publish("All", Time.format("%I:%M%p %d/%m/%Y")); // since without given time, now() is assumed

```

---

<div class="post-metadata">

**Author:** ![Ali](https://avatars.discourse-cdn.com/v4/letter/a/8c91f0/32.png) [@Ali](https://community.particle.io/u/Ali)\
**Post date:** [December 29, 2015, 4:14pm UTC](https://community.particle.io/t/photon-relay-shield-and-nextion-touchscreen-based-aquaponics-indoor-greenhouse/18366/19 "2015-12-29T16:14:16Z")

</div>

Thank you @ScruffR. You rock!!

---

<div class="post-metadata">

**Author:** ![Ali](https://avatars.discourse-cdn.com/v4/letter/a/8c91f0/32.png) [@Ali](https://community.particle.io/u/Ali)\
**Post date:** [December 29, 2015, 4:54pm UTC](https://community.particle.io/t/photon-relay-shield-and-nextion-touchscreen-based-aquaponics-indoor-greenhouse/18366/20 "2015-12-29T16:54:30Z")

</div>

I am using PietteTech\_DHT library for Temp and Humidity. And publishing at 20s intervals and i seem to get Raw sensor values every now and then. Any ideas on why this is happening

Any ideas on why this is happenning

 ![](https://us1.discourse-cdn.com/flex026/uploads/particle/original/2X/e/e9cf5dc643644c83c17c03fa9a1040ee7756fe4a.png)

[Next page](https://community.particle.io/t/photon-relay-shield-and-nextion-touchscreen-based-aquaponics-indoor-greenhouse/18366.md?page=2)
