basic sensor on bare atmega328p not working



  • Hello,

    I've recently begun building my first sensors. So far, I have an usb serial gateway talking with a humidity sensor (nano+dht22).

    My next step would be to build a sensor with the minimum components, and the first experimental step I've made almost works, but I get no value from the DHT22.

    My setup is :

    • breadboard with 3.3v power supply (YuRobot)
    • atmega328p running at 8Mhz on internal clock
    • nrf24L01+
    • DHT22 with data link tested on on 3 different digital pins
    • a led for debug purpose on digital pin 8
    • serial gateway plugged to a raspberry pi running domoticz
    • linux mint laptop with arduino IDE 1.6.7. Board is arduino Nano and upload is done with usbtinyISP 3.0

    The code is taken from HumiditySensor, slightly changed for debugging.

      if (isnan(temperature)) {
        Serial.println("Failed reading temperature from DHT");
        temperature = 0.0;
        gw.send(msgTemp.set(temperature, 1));
          
      } 
      else {
        lastTemp = temperature;
        gw.send(msgTemp.set(temperature, 1));
        Serial.print("T: ");
        Serial.println(temperature);
      }
    
    // same thing for humidity
    
      digitalWrite(led, HIGH);   // turn the LED on (HIGH is the voltage level)
      delay(500);       
      digitalWrite(led, LOW);    // turn the LED off by making the voltage LOW
      delay(500);               
    

    What happens is that the sensor is detected by the gateway and domoticz, but the readings are not numbers (see code above) and I get only zero on domoticz.
    I've swapped the DHT22 with the other working sensor : it works

    I've also tried with a DallasDS18B20 temp sensor and had a similar issue (I've not debbuged as much on that setup).

    I wonder if the programming should be done differently. I have tried adding a board definition taken from here : https://maniacbug.wordpress.com/2011/10/19/sensor-node/, but I may have bricked the chip as it does not anything anymore (no blinking led, no new value on domoticz), although the upload process works well.

    Would someone have an idea about what could be wrong with the setup ?

    Thanks in advance

    Mikael


  • Admin

    Might be a regression in master. So either switch to
    https://github.com/mysensors/Arduino/tree/development
    or back to
    https://github.com/mysensors/Arduino/releases/tag/1.5.1

    Until this is fixed.



  • Thanks for the tip.

    I reverted to 1.5.1 with a new atmega328p chip but it did not help, apart from the fact that the debug led now blinks and domoticz receives updated sendings with zeros.

    By the way, would anyone have a clue why my first atmega328p chip does not work even if it behaves well with avrdude and my isp ?

    Here is the output of avrdude : http://ur1.ca/ohh42

    When I burn a bootloader or upload a new sketch, I get no warning saying something goes wrong but my circuit does not work as with the new replacement chip.

    Regards

    Mikael

    edit : might have spoken too fast. I think I messed the revert to 1.5.1. I'll update soon.



  • Ok, sorry for previous reply : the revert was the right solution. Thanks again !

    If someone has a clue about diagnosing the first atmega328p chip, I'd be glad to hear about that.

    Regards

    Mikael



  • Hello,

    Two things :

    • first, the atmega chip was due to bad low fuse setting.

    • secondly, I had some luck when reverting to 1.5.1 and got a value on domoticz because the problem came back quickly. I tested my setup with 2 others ds18b20 temp sensors and it worked with only one of them. I checked again the DHT22 on my other sensor node (an arduino nano) and it works.

    It seems to me that my board has some issue, and one of those temp sensor is tolerant to it (I believe the other one works but I should check that). I Checked the voltage with my multimeter and it is 3.3v as it should. But I'm not experimented on electronics and I could have done some basic mistake.

    Would someone have any idea ?

    Regards
    Mikael


Log in to reply
 

Looks like your connection to MySensors Forum was lost, please wait while we try to reconnect.