Arduino Nano weather station

Hi,

I am working on the weather station project. I am using an Arduino Nano and custom made PCB's For the temperature and Humidity I am using DHT22 sensor and that is the one that is causing me some issues. The case is as follows:

  1. When I connect the DHT directly to the Arduino with 10cm jumper cables I can see in Serial monitor the correct data - so I assume that the code is fine.

  2. But when the sensor is connected via my custom PCB I do not have the readout - of course, the first assumption is that the hardware is faulty, but it seems not that plausible as:

a) All other sensors and LCD which is connected to the same PCB work, a soil moisture sensor for instance.
b) I have checked voltage on the DHT when everything is hooked up and it is 4.7V.
c) I have checked the signal pin if there is a connection between the DHT and corresponding pin in Arduino (A0) and there is a "beep" on my multimeter.
d) If it is relevant the Arduino is connected to PCB no.1 and the DHT is connected to the PCB no. 2 - both PCB's are connected with a flat 8 string ribbon cable which is around 50 cm long. So the cable length from the sensor (in total, so including the additional jumper cables and path length on the PCBs) is ~ 65-70 cm.
e) At first, I didn't have the pull-up resistor for DHT (when hooked directly to Arduino it was not necessary) but because of the length of the cable, I thought it might be a culprit. I have tested with 1K, 10K and 4,7K connected right at the DHT side as close to it as possible but no change, still no reading.
f) I have inspected the PCB visually and I don't see any faults, shorts etc.

So now I am a bit in the pickle and have no idea why I can't get any reading from it, please let me know what else I could or should attach for you to make it easier to troubleshoot this issue. For now, I am attaching the designs of the PCBs. Let me know if I should make any pictures of the boards? Or share the code, I don't think that is an issue as mentioned in point 1.

Not sure why but It seems I can't add the image, here is a direct link: Dropbox - File Deleted

To this PCB there is connected a DHT sensor, soil moisture sensor and LCD and then this PCB is connected with a flat ribbon to another PCB where Arduino sits.

I hope I have managed to describe everything clearly if there would be any more info needed, please let me know and thank you in advance for any tips.

PCB

Where is the code and the complete diagram? Please post it as stated in the How to use this forum sticky.

Bartosz_D:
If it is relevant the Arduino is connected to PCB no.1 and the DHT is connected to the PCB no. 2 - both PCB's are connected with a flat 8 string ribbon cable which is around 50 cm long.

Well, an 8-wire ribbon would not do a good job to connect to your 10-pin connector, would it? But that would prevent the LCD from working anyway.

Bartosz_D:
Not sure why but It seems I can't add the image, here is a direct link: Dropbox - File Deleted - Simplify your life

Because that is not a direct link to the image.

Oh well! At least surveyranger knows what a direct link is. :grinning:

If it works on one thing and not another, it is indeed a puzzle. Without the pattern of the other board, there is not much else to say.

However, a design point about this PCB. You have unfortunately routed the +5 V line through the pad for R1. I advise you to cut those traces and re-join them so that R1 does not connect to the 5 V line; if you make more boards, correct the routing accordingly. This will make it easier to adjust the contrast and incidentally, save you half a milliamp in current draw.

Hi both, thank you for the initial tips!

Sorry about the misleading 8-wire ribbon, indeed it is, of course, 10-wire one so it fits the connector, that was just a typo.

Here I am attaching again the pictures of PCBs, hope it is correct now:

PCB1 layout:

PCB1 schematics:

PCB2:

PCB2 schematics:

And here is the code (but as mentioned before I doubt it is the code due to the fact that DHT directly on Arduino works), also it is trimed as I got message I have exceeded 9000 characters writing the post:

/*
...

//Presure  sensor activation
Adafruit_BMP085_Unified bmp = Adafruit_BMP085_Unified(10085);

//temperature and moisture sensor  activation
dht DHT;
#define dht_dpin A0 //no ; here. Set equal to channel sensor is on


//LCD activation and pin set up
LiquidCrystal lcd (12, 11, 5, 4, 3, 2);

...

//stepper motor pin configuration
 int
  PIN_ENABLE1 = 7,
  PIN_STEP1 = 6,
  PIN_DIR1 = 10,
  
  STEPS = 200,
  PAUSE = 500,       // Milliseconds
  STEP_DELAY = 500;  // Microseconds
  
//pins declaration   
const byte hold_water_button = 9;
const byte add_water_button = 8;
int v_pot = analogRead(A3);

float timeout_water = 1000; //water run time   10sec = 20 ml

//bit that is setting up timer for different sensors 
typedef void (*command)();

template <unsigned long wait_ms, command c>
void repeat() {
    static unsigned long start = millis();
    if (millis()-start >= wait_ms) {
        start += wait_ms;
        c();
    }
}

//void for potentiometer readings
void pot_read()
{
int v_pot = analogRead(A3);
int v_pot_ml = map(v_pot, 40, 1015, 1, 101);

timeout_water = (v_pot_ml/2)*1000;

//LCD output
  
  lcd.createChar(7, vol);
  lcd.setCursor(8,1);
  lcd.write(byte(7));
  lcd.print(v_pot_ml);
  lcd.print("ml");
  lcd.print(" ");
}

//void for humidyty, temperature and moiture sensors
void HTMP_read()
{
// pinMode(A0, INPUT_PULLUP); 
//temp & humidity
DHT.read22(dht_dpin);

//Moisture
int soil_moist = analogRead(A1); //take a sample
int soil_moist2 = map(soil_moist, 314, 1020, 99, 0); //maping moisture for 0-100% 

//presure 
sensors_event_t event;
bmp.getEvent(&event);
float seaLevelPressure = SENSORS_PRESSURE_SEALEVELHPA;

//LCD output

  lcd.createChar(3, hum);
  lcd.setCursor(0,0);
  lcd.write(byte(3));
  lcd.print(round(DHT.humidity));
  lcd.print("%");
  
  lcd.createChar(4, moist);
  lcd.setCursor(5,0);
  lcd.write(byte(4));
  lcd.print(soil_moist2);
  lcd.print("%");
  lcd.print(" ");
  
  lcd.createChar(5, temp);
  lcd.setCursor(10,0);
  lcd.write(byte(5));
  lcd.print(DHT.temperature, 1);
  lcd.print("C");
  
  lcd.createChar(6, pressure);
  lcd.createChar(0, h);
  lcd.createChar(1, pa);
  lcd.setCursor(0,1);
  lcd.write(byte(6));
  lcd.print(event.pressure, 0);
  lcd.write(byte(0));
  lcd.write(byte(1));
  lcd.print(" ");
  
  //moisture assessment display -  test whether the arrows are working as supposed 

 if        (soil_moist > 850) 
           {lcd.setCursor(15,1);
           lcd.print("-");}      
 else if   (soil_moist <= 850 && soil_moist > 600) 
           {lcd.setCursor(15,1);
           lcd.write(byte(2));}
 else  
           {lcd.setCursor(15,1);
           lcd.print("+");}
    
       
//serial output

    Serial.print("Humidity = ");
    Serial.print(DHT.humidity);
    Serial.println(" %  ");
    Serial.print("Temperature = ");
    Serial.print(DHT.temperature); 
    Serial.println(" C  ");
    Serial.print("Moisture = ");
    Serial.print(soil_moist2);
    Serial.println(" %  ");
    Serial.print("Pressure = ");
    Serial.print(event.pressure);
    Serial.println(" hPa  ");
    Serial.print("Altitude = "); 
    Serial.print(bmp.pressureToAltitude(seaLevelPressure,
                                        event.pressure)); 
    Serial.println(" m ");
      
}

void setup() 
{
  
Serial.begin(9600);
!bmp.begin(); 

//pins configuration
  pinMode(PIN_ENABLE1, OUTPUT);      // Enable
  pinMode(PIN_STEP1, OUTPUT);        // Step
  pinMode(PIN_DIR1, OUTPUT);         // Dir
  digitalWrite(PIN_ENABLE1, HIGH);    // Set Enable low == turned on..
  digitalWrite(PIN_DIR1, LOW);       // Set Dir high  
   
  pinMode(hold_water_button, INPUT_PULLUP); //button pin as input w/internal pull-up
  pinMode(add_water_button, INPUT_PULLUP);
  
  pinMode(A1, INPUT); //set up analog pin 1 for moisture sensor
  pinMode(A3, INPUT); //set up analog pin 3 for volume potentiometer
  
  lcd.begin(16, 2); //lcd enable
  lcd.setCursor(2,0);
  lcd.print("Hello, World!");
  delay(2000);
  lcd.clear();
  
}

//loop test for button pressed
void loop() 
{
 
//button settings  
if (!digitalRead(add_water_button)) 
{ 
        delay(30);                            //wait for a while, to avoid bounces
        if (!digitalRead(add_water_button))  //the button is still pressed, it wasn't a bounce then execute this function:
          {add_water();} 
       else
    {digitalWrite(PIN_ENABLE1, HIGH);}
} 
    
if (digitalRead(hold_water_button) == LOW)
          {hold_water();}
        else  
            {  
      //Sensors voids call  
      repeat<100, pot_read>();
      repeat<10000, HTMP_read>();
      digitalWrite(PIN_ENABLE1, HIGH);
            }
            
}

//do your stuff until timeout
void add_water() 
{
    unsigned long startingTime; //used to store the starting moment
    startingTime = millis();    // loop until condition breaks ie. timeout
  
    do {
       digitalWrite(PIN_ENABLE1, LOW);
       digitalWrite(PIN_DIR1, LOW);       // Set Dir high
       digitalWrite(PIN_STEP1, HIGH);   // Output high
       delayMicroseconds(STEP_DELAY);  // Wait 1/2 a ms
       digitalWrite(PIN_STEP1, LOW);    // Output low
       delayMicroseconds(STEP_DELAY);  // Wait 1/2 a ms    
       } while ((millis() - startingTime) < timeout_water);
}
  
  
void hold_water() 

{   
       digitalWrite(PIN_ENABLE1, LOW);
       digitalWrite(PIN_DIR1, LOW);       // Set Dir high
       digitalWrite(PIN_STEP1, HIGH);   // Output high
       delayMicroseconds(STEP_DELAY);  // Wait 1/2 a ms
       digitalWrite(PIN_STEP1, LOW);    // Output low
       delayMicroseconds(STEP_DELAY);  // Wait 1/2 a ms       
}

Regarding the resistor and the 5V line thanks! I have noticed that as well after assembly, but could that somehow be connected to DHT? Could it not be receiving enough milliamps? I have tried to run it without other parts like LCD and moisture sensor and the result is the same - no result.

I hope that now with the updated information you will be able to have some more insights, thank you very much in advacne!

Non of your pictures show up here, went don't you use the forum own upload option?

Bringamosa:
None of your pictures show up here, went don't you use the forum own upload option?

Unnecessary (and clumsy). What is needed is to identify the actual picture link.

Bring up the image in question on the hosted page. Right click and select "View Image". If you cannot get that option - or indeed any option on a right click, it means the web page is deliberately obfuscating that link (such as Google Drive does) and you are using the wrong image hosting site.

Once you have the image itself - and nothing else - displayed in your browser tab, right click and choose "Copy Image Location". Then paste that into the image insertion option.

Paul__B:
Unnecessary (and clumsy). What is needed is to identify the actual picture link.

Bring up the image in question on the hosted page. Right click and select "View Image". If you cannot get that option - or indeed any option on a right click, it means the web page is deliberately obfuscating that link (such as Google Drive does) and you are using the wrong image hosting site.

Once you have the image itself - and nothing else - displayed in your browser tab, right click and choose "Copy Image Location". Then paste that into the image insertion option.

My whole point is there is no image to be seen. The link to dropbox gives an 401 error.

I aggree the attachment procedure is clumsy, but at least the images will be there :wink:

Hi, I was hoping it is already fine as when I use the forums preview option I can see the pictures, which was not the case in my original post, so I thought the issue is solved. Paul__B that is exactly what I have done in order to get the link.

I have now used the attachment option, is it possible for you guys to see it?

Sorry for all the trouble!

Bartosz_D:
Hi, I was hoping it is already fine as when I use the forums preview option I can see the pictures, which was not the case in my original post, so I thought the issue is solved. Paul__B that is exactly what I have done in order to get the link.

I have now used the attachment option, is it possible for you guys to see it?

Sorry for all the trouble!

Yes they are up for donload. Only need some image tags. Copy the link of the attached image by rightclicking and copying. Then use the add image icon or just put thrm between the image tags.

[Img]link to image[/img]

Bringamosa:
My whole point is there is no image to be seen. The link to dropbox gives an 401 error.

Funny. Worked fine for me, still does!

Hmm, still the dropbox link is don't work for me.... Strange

Bringamosa thanks for attaching them correctly I will know now for the next time!

So do we have all the information now, any ideas about the original problem?

Or should I give some more input, I completely run out of ideas what could be wrong here.

EDIT: I would really appreciate any kind of help :slight_smile: It is driving me crazy not to be able to find an issue here.

EDIT2: Can the backlight of the LCD be taking up too much current?

Hi guys, sorry for the "post under post" but I would really appreciate some help, I hope you understand :wink:

Anybody, any ideas?

Another question popped up as you can see on the schematics there is a space for a 12V external input so the Arduino does not need to be powered from USB. I have just connected a DC 12V 2A power adapter and it seems to have killed my Arduino ;( I am also in doubt why has this happened as I can't see the error. Arduino should accept 6-20V on Vin pin.

The obsolete tutorials on the Arduino site and others imply that the largely ornamental "barrel jack" (on the UNO) and "Vin" connections to the on-board regulator imply that this is a usable source of 5 V power. This is absolutely not the case. It is essentially only for demonstration use of the bare board back in the very beginning of the Arduino project when "9V" transformer-rectifier-capacitor power packs were common and this was a practical way to power a lone Arduino board for initial demonstration purposes. And even then it was limited because an unloaded 9 V transformer-rectifier-capacitor supply would generally provide over 12 V which the regulator could barely handle.

This is because the on-board regulator is essentially capable of powering only the microcontroller itself and no more than a couple of indicator LEDs. The on-board regulator might be able to power a few other things if it had a heatsink, but on the Arduinos, it does not.

A practical power supply for the Nano (or UNO, Pro Mini, Leonardo etc.) is a "phone charger" with a USB output connector for 5 V, generally up to a couple of Amps though you can not feed more than 500 mA through the USB connection.

If you want to power it from 12 V or a car system, you need a 5 V switchmode "buck" regulator to supply the 5 V.

I have a simple lm7805 bringing my 11 tot 15 volt from my campervan leisure battery down to 5v. This works for me.

I also have a simple step down converter to get the same voltage down to 3.3v for my esp8266 project. Just make sure you choose one that can deliver the amperage you need. For the chineese ones i never use more than half they are rated for. Works great.

Once set at desired voltage i drop a dab of hotglue on the set screw. To remove is just dip a qtip in isoproalcohol, and wet the gotglue with that. It will release very easily.

Bringamosa:
I have a simple lm7805 bringing my 11 tot 15 volt from my campervan leisure battery down to 5v. This works for me.

With a big heatsink.

Bringamosa:
Once set at desired voltage i drop a dab of hot glue on the set screw. To remove is just dip a qtip in isopropyl alcohol, and wet the hot glue with that. It will release very easily.

Excellent idea. Better the ones with the multi-turn enclosed pot - that is the biggest concern I have with these regulators - if the pot fails, everything fails.

Yeah i agree that these setscrews are not the best. Next batch of buck converters will be those with the enclosed pot you mentioned.

Pail__N and Bringamosa, thank you very much for the swift answers. Did I understand you correctly that even though in the Arduino Nano (one I am using) datasheet it states that acceptable voltage for Vin is 6-20V (recommended 7-12V) I can not use it? I need 12V to run the stepper motor and I thought that I can use one single DC power supply to run it and give the Arduino the juice its need without any additional hardware. I am assuming that it has enough current to run all the sensors I hooked up as it works all fine when connected to the USB - well besides this DHT22 but that is another issue. I have to also mention that at the stage of the prototype when I had everything on the breadboard there were no issues and everything worked as supposed using same supply on the Vin.

What have hanged now is the new custom made PCB which I blame for all the recent mishaps, but because my PCB design skills are super novice I am unable to find mistakes that are causing that. Maybe there are some major issues in the concept itself but then why my prototype was all good?

What do you think about that?

You can use the 12v to power your additional equipment but it is better to seperate/split that supply and step down the voltage for your arduino.