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

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.


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

    uint32_t number = 0;


    if (number == 1)
        number = 2;    
        number = 1;

void setup(void)
    dbSerialPrintln("setup done");

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 :blush:)

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.

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

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.

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.

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.

 * VERSION:     0.3
 * PURPOSE:     Example that uses DHT library with two sensors
 * LICENSE:     GPL v3 (
 * 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)
 *      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.

works now!!


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.

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

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

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

Where 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” :wink:

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.

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”.

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

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)

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

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

No the easiest way is

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

void loop
  Particle.publish("All", Time.format());

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

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

Thank you @ScruffR. You rock!!


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