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.

5 Likes

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

{
    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");

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

works now!!

2 Likes

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() {
    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

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(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?

No the easiest way is

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()

  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!!

2 Likes

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