wireless temperature sensor


Posted on Feb 5, 2014

Here`s the Arduino code for reading incoming packets from the XBee and displaying the received analog sample on the LED display. Parsing an XBee packet is quite complex, unfortunately. But after studying the documentation for a while, it isn`t that hard. #define NUM_DIGITAL_SAMPLES 12 #define NUM_ANALOG_SAMPLES 4 int groundPins[7] = {8, 2, 3, 4, 5


wireless temperature sensor
Click here to download the full size of the above Circuit.

, 9, 7}; int digitPins[2] = {11, 10}; int ON = HIGH; int OFF = LOW; int number[10][7]; int digit[2]; int TOP = 0; int UPPER_L = 1; int LOWER_L = 2; int BOTTOM = 3; int LOWER_R = 4; int UPPER_R = 5; int MIDDLE = 6; int index; int n = 0; int packet[32]; int digitalSamples[NUM_DIGITAL_SAMPLES]; int analogSamples[NUM_ANALOG_SAMPLES]; void setup() { Serial. begin(9600); for(int i=0;i<7;i+) { pinMode(groundPins[i], OUTPUT); } for(int i=0;i<2;i+) { pinMode(digitPins[i], OUTPUT); } initNumber(); setDigit(n); } void loop() { readPacket(); drawDisplay(); } void readPacket() { if (Serial. available() > 0) { int b = Serial. read(); if (b = 0x7E) { packet[0] = b; packet[1] = readByte(); packet[2] = readByte(); int dataLength = (packet[1] << 8) | packet[2]; for(int i=1;i<=dataLength;i+) { packet[2+i] = readByte(); } int apiID = packet[3]; packet[3+dataLength] = readByte(); // checksum printPacket(dataLength+4); if (apiID = 0x92) { int analogSampleIndex = 19; int digitalChannelMask = (packet[16] << 8) | packet[17]; if (digitalChannelMask > 0) { int d = (packet[19] << 8) | packet[20]; for(int i=0;i < NUM_DIGITAL_SAMPLES;i+) { digitalSamples[i] = (d >> i) & 1); } analogSampleIndex = 21; } int analogChannelMask = packet[18]; for(int i=0;i<4;i+) { if (analogChannelMask >> i) & 1) { analogSamples[i] = (packet[analogSampleIndex] << 8) | packet[analogSampleIndex+1]; analogSampleIndex += 2; } else { analogSamples[i] = -1; } } } } int reading =...




Leave Comment

characters left:

Related Circuits

  • New Circuits

    .

     


    Popular Circuits

    Baseband Circuits for an RFID Receiver
    HAM Modulation Monitor
    Soft Musical Telephone Ringer by UM66T
    astable multivibrator
    3D Laser Scanner
    80M CW QRP rig
    JCM800 2204 bias problem
    Power disconnection alarm circuit diagram
    Four gas monitor circuit diagram



    Top