External sensors at the XDK gateway
응답
16. 6. 28 오후 1:50

Hello - i have got a very good mqtt solution from Christopher Koch to connect the XDK in a very easy way to my own smarthome application, also transmitting sensor data to my IPhone via my particle photons. Next milestone should be to connect external sensors, actors to the XDK gateway - also the easy way and controll and call them the same way as already - via mqtt calls and answers.
So i need some help again - idea is to implement virtual sensors - digital and analog - which provide only their status in the mqtt answer. If have made first test with a mercury sensor (see picture) - looks fine and works - i now only need some code snipets more in the already existing xdk application to let the XDK read the digital 0 pin and later an analog 0 pin etc.

 

+1 (1 투표)
RE: External sensors at the XDK gateway
응답
16. 6. 29 오후 12:05 as a reply to Achim Kern.

Hello Achim,

nice to hear that the mqtt solution of Christopher Koch worked out for you.
We are glad that you share your experience with us.

I will add this to our improvement list.
We will release an extension board guide with code snippets that might help you to implement this on your own. It will come soon.

Stay tuned.

- Manuel

0 (0 투표)
RE: External sensors at the XDK gateway
응답
16. 6. 30 오전 9:31 as a reply to Manuel Cerny.

Perfekt - today i got the update from Christopher Koch.
I will make first tests next week.

I have done a quick implementation of the code you asked for. 
Please let me know how it works for you.  A couple of things of note.

  • The raw ADC Values will go from 0 to 4095 corresponding to 0V – 2.5V.
  • The MCU is powered by 2.5V.  So the max voltage on an input pin should be 2.8V (VDD+0.3).  I would recommend using a voltage divider on the sensor you are using so the input to the MCU isn’t 3.3V.  A voltage divider with Rt = 3.24K and Rb = 10k should work, where Rt is the top resistor and Rb is the bottom resistor in the voltage divider.  This should give you 2.49V input into the MCU when the sensor outputs a high of 3.3V.

here a snipet out of the code

if (DIG_IN_PA1_EN == ENABLED) {

sensorStreamBuffer.length += sprintf(sensorStreamBuffer.data + sensorStreamBuffer.length, "PA1 Input = %d\n", _pa1State);

}

if (DIG_IN_PE2_EN == ENABLED) {

sensorStreamBuffer.length += sprintf(sensorStreamBuffer.data + sensorStreamBuffer.length, "PE2 Input = %d\n", _pe2State);

}

if ((ADC0_CH5_EN == ENABLED) && (ADC0_CH6_EN == ENABLED)) {

sensorStreamBuffer.length += sprintf(sensorStreamBuffer.data + sensorStreamBuffer.length, "ADC Ch5 = %ld\n", _adcCh5);

sensorStreamBuffer.length += sprintf(sensorStreamBuffer.data + sensorStreamBuffer.length, "ADC Ch6 = %ld\n", _adcCh6);

}

else if (ADC0_CH5_EN == ENABLED) {

sensorStreamBuffer.length += sprintf(sensorStreamBuffer.data + sensorStreamBuffer.length, "ADC Ch5 = %ld\n", _adcCh5);

}

else if (ADC0_CH6_EN == ENABLED) {

sensorStreamBuffer.length += sprintf(sensorStreamBuffer.data + sensorStreamBuffer.length, "ADC Ch6 = %ld\n", _adcCh6);

}

0 (0 투표)
RE: External sensors at the XDK gateway
응답
16. 6. 30 오후 1:23 as a reply to Achim Kern.

Hello Achim,

thank you very much for sharing your code snippets with the XDK community.
Please keep us posted. 

- Manuel

0 (0 투표)
RE: External sensors at the XDK gateway
응답
16. 7. 2 오전 6:11 as a reply to Manuel Cerny.

Hello - and here the first results

Device: XDK110
Name: 20C38FF5ECD7
Timestamp: 136
acc (mG):
     x = +20 
     y = -17 
     z = +1011
gyro (mdeg/s):
     x = -5126
     y = +610
     z = -2807
mag (uT):
     x = +3  
     y = +24 
     z = +31 
light (mLux) = 14400
temp (mCelsius) = 31850
pressure (Pascal) = 98488
humidity (%rh) = 41
PA1 Input = 1
PE2 Input = 1
ADC Ch5 = 2928
ADC Ch6 = 3101

that looks pretty good - software works.
Next step - testing a bunch of external sensors on the XDK.

 

0 (0 투표)
RE: External sensors at the XDK gateway
응답
16. 7. 2 오전 7:50 as a reply to Achim Kern.

First test runs with a mercury sensor - works perfect !!!
Best of all - i do not need a voltage divider - cause i could use the XDK 2.5V supply.

Normally the sensors need 3.3V or 5.0V to work.
Here the results - sensor is on port PA1 and Input = 0 which means he is closed.

So well done - Mr. Koch - more to come - if i have more time - must no work in the kitchen...

Device: XDK110
Name: 20C38FF5ECD7
Timestamp: 456
acc (mG):
     x = +14 
     y = +26 
     z = +1014
gyro (mdeg/s):
     x = -5249
     y = +2197
     z = +4150
mag (uT):
     x = +3  
     y = +28 
     z = +18 
light (mLux) = 43200
temp (mCelsius) = 28320
pressure (Pascal) = 98458
humidity (%rh) = 46
PA1 Input = 0
PE2 Input = 1
ADC Ch5 = 4008
ADC Ch6 = 3884
 

0 (0 투표)
RE: External sensors at the XDK gateway
응답
16. 7. 4 오전 7:12 as a reply to Achim Kern.

Hello Achim,

nice to see that you are making progress.
Please keep us updated.

- Manuel

0 (0 투표)