First thing first - the contestants are:
- TMP100 - I2C based sensor from TI in SOT23-6 package
- DS1820 (and similar ones) - 1-Wire based sensor from Dallas / Maxim
- DHT22 - sort of one-wire protocol, temperature and humidity, based on AM2302
As always, I took Arduino, attached LCD display to it and all three sensors, using sample code from Arduino libraries. I did not see any example for TMP100, but Google suggested the Fork Robotics page, and the example described on that page worked just fine. I do not offer the code for download, it's a big mess, and throwing it together took me about ten minutes anyway.
The results are interesting, and reassuring me I can use any kind of sensor without risking the temperatures being too different compared to any other sensor. In other words, I can use the DHT22 for the meteo node, and trust the temperature. There is no need for an additional DS18xx sensor on that node.
I tweaked the code for the central node a little, nothing important. I am considering a change of the packet definition, making just a single structure that will use anonymous structures and unions to describe any kind of sensor packet. I am still not sure if there are any drawback other than the obvious one (prone to mistake). Just to explain what do I mean:
typedef union {This allows me to directly refer to PacketType, BattLevel etc. without 'going into' the Temp structure. Arduino supports this, at least the 1.5.8 version.
SensorPayloadTemperature_t Temp;
SensorPayloadMeteo_t Meteo;
struct {
uint8_t PacketType;
uint8_t BattLevel;
uint8_t ___pad[2];
uint16_t SensorId;
};
} SensorPayload_t;
Žádné komentáře:
Okomentovat