Let's say the letter "T" for Temperature and "H" for Humidity. The messages would be just as the one in my code but with one char added to identify the message on the receiving end. I would send the data in two separate messages. I'm no expert and there are probably better solutions than the one I will suggest but I'll try to point you in a good direction. However I guess you want to send both humidity and temperature. If you want to send a longer number you just need to change the number of chars in the char array. I suggest you try this code first with a simple potentiometer or something to make sure you connection works. With my code you can send any 4 digit integer with virtual wire it doesn't matter if it's from an analog sensor, digital sensor or just made up. Serial.println("Failed to read from DHT") check if returns are valid, if they are NaN (not a number) then something went wrong! Connect a 10K resistor from pin 2 (data) to pin 1 (power) of the sensor Connect pin 4 (on the right) of the sensor to GROUND Connect pin 2 of the sensor to whatever your DHTPIN is Connect pin 1 (on the left) of the sensor to +5V #define DHTPIN 2 // what pin we're connected to Next the sketch I use for the DHT22 sensor alone: Is it possible read an digital sensor (DHT22) instead of an analog sensor? Can you help me? I will use a DHT22 sensor with RF and Virtual wire. Turn off light to and await next message Convert Sensor1CharMsg Char array to integer when the incoming messages has less digits than the This needs to be done otherwise problems will occur Fill Sensor1CharMsg Char array with corresponding Message with a good checksum received, dump it. Turn on a light to show received good message Gets a sensor reading 0-1023 in a char array Vw_wait_tx() // Wait until the whole message is goneĭigitalWrite(13, false) // Turn off a light after transmission Vw_send((uint8_t *)Sensor1CharMsg, strlen(Sensor1CharMsg)) Convert integer data to Char array directlyĭigitalWrite(13, true) // Turn on a light to show transmitting The code and comments below are pretty much self explanatory:
0 Comments
Leave a Reply. |
AuthorWrite something about yourself. No need to be fancy, just an overview. ArchivesCategories |