Navigation

    • Register
    • Login
    • OpenHardware.io
    • Categories
    • Recent
    • Tags
    • Popular
    1. Home
    2. tssk
    3. Topics
    • Profile
    • Following
    • Followers
    • Topics
    • Posts
    • Best
    • Groups

    Topics created by tssk

    • tssk

      ArduinoShrink
      Development • • tssk  

      5
      0
      Votes
      5
      Posts
      78
      Views

      skywatch

      @bjacobse I was surprised too as like you I had seen that they would not work with mysensors and definitely not with debug output - with 2 switches I was able to use debug output, but not after adding the htu21d (which I expected to fail, but after a little code change worked well). We live, We learn!
    • tssk

      How to manage dynamic number of sensors?
      Development • • tssk  

      6
      0
      Votes
      6
      Posts
      58
      Views

      tssk

      In case someone is interested in the code for mysensors mqtt gateway using the DS2482.h library from https://github.com/paeaetech/paeae. The temperature conversion code is from example. I am omitting the mysensors setup. ... #include <DS2482.h> #include <Ethernet.h> #include <MySensors.h> #include <Wire.h> DS2482 ds( 0 ); //channels ds2482-800 is 0 to 7, DS2482-100 is just set 0 byte dsData[8]; //holding for onewire capture byte dsAddr[8]; //1wire wire address and CRC MyMessage msgAddr( 0, V_ID ); MyMessage msgTemp( 0, V_TEMP ); void setup() { //Uses Wire library to communicate with DS2482 so be sure to call Wire.begin() before using the library. Wire.begin(); ds.reset(); } void presentation() { // Send the sketch version information to the gateway and Controller sendSketchInfo( SKETCH_NAME, SKETCH_MAJOR_VER "." SKETCH_MINOR_VER ); } void loop() { #ifdef MY_DEBUG Serial.println( "DBG: loop start" ); #endif ds.wireResetSearch(); ds.wireReset(); ds.wireSkip(); //need to send high power to bus?? Adding 5 volts to devices makes it work. ds.wireWriteByte( 0x44 ); //convert temperature on all devices delay( 1000 ); byte sensorId = 0; while( ds.wireSearch( dsAddr ) ) { #ifdef MY_DEBUG Serial.print( sensorId ); Serial.print( " : " ); #endif char sensorAddr[17]; //eg. 280838211713012D for( int i = 0; i < 8; i++ ) { sensorAddr[i*2] = ( dsAddr[i] >> 4 ) + 0x30; if ( sensorAddr[i*2] > 0x39 ) { sensorAddr[i*2] += 7; } sensorAddr[i*2+1] = ( dsAddr[i] & 0x0f ) + 0x30; if ( sensorAddr[i*2+1] > 0x39 ) { sensorAddr[i*2+1] += 7; } } sensorAddr[16] = '\0'; //always zero terminate string #ifdef MY_DEBUG Serial.print( sensorAddr ); Serial.print( "\n" ); #endif send( msgAddr.setSensor( sensorId ).set( sensorAddr ) ); #ifdef MY_DEBUG Serial.print( sensorId ); Serial.print( " : " ); #endif if ( ds.crc8( dsAddr, 7 ) != dsAddr[7] ) { Serial.print( "CRC is not valid!" ); return; } /* //test if device code DS18B20 if ( dsAddr[0]==0x28 ) { //test if device code MAX31850 if ( dsAddr[0]==0x3B ) { */ //read temperature data. ds.wireReset(); //ds.reset(); ds.selectChannel( 0 ); //necessary on -800 ds.wireSelect( dsAddr ); ds.wireWriteByte( 0xbe ); // Read Scratchpad command //display hex values of scratchpad for ( int i = 0; i < 9; i++ ) { // we need 9 bytes dsData[i] = ds.wireReadByte(); #ifdef MY_DEBUG if ( dsData[i] < 16 ) { Serial.print( "0" ); } Serial.print( dsData[i], HEX ); #endif } //convert to decimal temperature int LowByte = dsData[0]; int HighByte = dsData[1]; int TReading = ( HighByte << 8 ) + LowByte; int SignBit = TReading & 0x8000; // test most sig bit if ( SignBit ) // negative { TReading = ( TReading ^ 0xffff ) + 1; // 2's comp } float Tc_100 = (double) TReading * 0.0625; if ( SignBit ) { // If its negative Tc_100 = 0 - Tc_100; } //print temp for each device #ifdef MY_DEBUG Serial.print( " : " ); Serial.println( Tc_100 ); #endif send ( msgTemp.setSensor( sensorId ).set( Tc_100, 2 ) ); sensorId++; } #ifdef MY_DEBUG Serial.println( "DBG: loop end" ); #endif delay( 60000 ); } I am of course happy for any feedback. Especially if I am doing anything stupid as I am no programmer
    • tssk

      Missing data for some sensors when define MY_DEBUG is disabled [SOLVED]
      Bug Reports • • tssk  

      8
      0
      Votes
      8
      Posts
      50
      Views

      ejlane

      @mfalkvidd In addition, since the later sensors are seeing it, it's probably just that the power supply is drooping before the voltage regulation on it can catch up. They kind of have 'inertia' and can take a bit to respond, and of course every power supply is different, based on how it's built. So likely the capacitors are helping it ride through the first transmission, and then the power supply 'catches up' for the later ones, but the second one gets garbled with the lower power, and the receiving radio chucks it as a bad packet.
    • tssk

      Which radio / wireless module to choose? Please recommend
      Hardware • • tssk  

      20
      0
      Votes
      20
      Posts
      193
      Views

      tssk

      I finished gateway for my attic - What did you build today (Pictures) ?: As this will be under roof but without any isolation I try to put small silica gel bag (I collect them from other electronics packaging) inside and will see. I think it should be suitable. I am thinking of adding temperature and humidity sensor... that could also help me show how much humidity is around the year actually. I might use the resin / epoxy stuff for some watering projects
    • tssk

      Ethernet / MQTT PoE gateway for 16 reed switches
      My Project • • tssk  

      4
      2
      Votes
      4
      Posts
      72
      Views

      tssk

      So I finally changed the splitter connector to USB micro and it is a bit more polished now I also connected it to openHab2 via MQTT binding. So in case any one is interested here is the configuration for the thing and items. Bridge mqtt:broker:openhab [ host="localhost" ] { Thing topic mag "Magnety" { Channels: Type contact : pin17 [ stateTopic="mag-out/0/17/1/0/16", on="1", off="0"] Type contact : pin16 [ stateTopic="mag-out/0/16/1/0/16", on="1", off="0"] Type contact : pin15 [ stateTopic="mag-out/0/15/1/0/16", on="1", off="0"] Type contact : pin14 [ stateTopic="mag-out/0/14/1/0/16", on="1", off="0"] Type contact : pin1 [ stateTopic="mag-out/0/1/1/0/16", on="1", off="0"] Type contact : pin0 [ stateTopic="mag-out/0/0/1/0/16", on="1", off="0"] Type contact : pin2 [ stateTopic="mag-out/0/2/1/0/16", on="1", off="0"] Type contact : pin3 [ stateTopic="mag-out/0/3/1/0/16", on="1", off="0"] Type contact : pin4 [ stateTopic="mag-out/0/4/1/0/16", on="1", off="0"] Type contact : pin5 [ stateTopic="mag-out/0/5/1/0/16", on="1", off="0"] Type contact : pin6 [ stateTopic="mag-out/0/6/1/0/16", on="1", off="0"] Type contact : pin7 [ stateTopic="mag-out/0/7/1/0/16", on="1", off="0"] Type contact : pin8 [ stateTopic="mag-out/0/8/1/0/16", on="1", off="0"] Type contact : pin9 [ stateTopic="mag-out/0/9/1/0/16", on="1", off="0"] Type contact : pin19 [ stateTopic="mag-out/0/19/1/0/16", on="1", off="0"] Type contact : pin18 [ stateTopic="mag-out/0/18/1/0/16", on="1", off="0"] } } Contact mag17 "Magnet 17" <window> { channel="mqtt:topic:openhab:mag:pin17" } Contact mag16 "Magnet 16" <window> { channel="mqtt:topic:openhab:mag:pin16" } Contact mag15 "Magnet 15" <window> { channel="mqtt:topic:openhab:mag:pin15" } Contact mag14 "Magnet 14" <window> { channel="mqtt:topic:openhab:mag:pin14" } Contact mag1 "Magnet 1" <window> { channel="mqtt:topic:openhab:mag:pin1" } Contact mag0 "Magnet 0" <window> { channel="mqtt:topic:openhab:mag:pin0" } Contact mag2 "Magnet 2" <window> { channel="mqtt:topic:openhab:mag:pin2" } Contact mag3 "Magnet 3" <window> { channel="mqtt:topic:openhab:mag:pin3" } Contact mag4 "Magnet 4" <window> { channel="mqtt:topic:openhab:mag:pin4" } Contact mag5 "Magnet 5" <window> { channel="mqtt:topic:openhab:mag:pin5" } Contact mag6 "Magnet 6" <window> { channel="mqtt:topic:openhab:mag:pin6" } Contact mag7 "Magnet 7" <window> { channel="mqtt:topic:openhab:mag:pin7" } Contact mag8 "Magnet 8" <window> { channel="mqtt:topic:openhab:mag:pin8" } Contact mag9 "Magnet 9" <window> { channel="mqtt:topic:openhab:mag:pin9" } Contact mag19 "Magnet 19" <window> { channel="mqtt:topic:openhab:mag:pin19" } Contact mag18 "Magnet 18" <window> { channel="mqtt:topic:openhab:mag:pin18" } Quick preview in openHab2 PaperUI I would also like to share the arduino code as I have some question. #include <Ethernet.h> #include <MySensors.h> #define SKETCH_NAME "Magnety" #define SKETCH_MAJOR_VER "1" #define SKETCH_MINOR_VER "0" byte pins[] = { 17, 16, 15, 14, 1, 0, 2, 3, 4, 5, 6, 7, 8, 9, 19, 18 }; int sentValues[16] = { 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1 }; MyMessage messages[16] = { MyMessage( 17, V_TRIPPED ) ,MyMessage( 16, V_TRIPPED ) ,MyMessage( 15, V_TRIPPED ) ,MyMessage( 14, V_TRIPPED ) ,MyMessage( 1, V_TRIPPED ) ,MyMessage( 0, V_TRIPPED ) ,MyMessage( 2, V_TRIPPED ) ,MyMessage( 3, V_TRIPPED ) ,MyMessage( 4, V_TRIPPED ) ,MyMessage( 5, V_TRIPPED ) ,MyMessage( 6, V_TRIPPED ) ,MyMessage( 7, V_TRIPPED ) ,MyMessage( 8, V_TRIPPED ) ,MyMessage( 9, V_TRIPPED ) ,MyMessage( 19, V_TRIPPED ) ,MyMessage( 18, V_TRIPPED ) }; void setup() { byte pinsCount = sizeof( pins ) / sizeof( pins[0] ); for( byte i = 0; i < pinsCount; i++ ) { pinMode( pins[i], INPUT ); } } void presentation() { // Send the sketch version information to the gateway and Controller sendSketchInfo(SKETCH_NAME, SKETCH_MAJOR_VER "." SKETCH_MINOR_VER); byte pinsCount = sizeof( pins ) / sizeof( pins[0] ); for( byte i = 0; i < pinsCount; i++ ) { //This seems not to be usefull with openhab mqtt bindings //present( pins[i], S_DOOR ); //But this seems to be more uefull when controller is started after gateway send( messages[i].set( sentValues[i] ) ); } } void loop() { int value; // Short delay to allow buttons to properly settle sleep(5); byte pinsCount = sizeof( pins ) / sizeof( pins[0] ); for( byte i = 0; i < pinsCount; i++ ) { value = digitalRead( pins[i] ); if ( value != sentValues[i] ) { // Value has changed from last transmission, send the updated value send( messages[i].set( value==HIGH ? 1 : 0 ) ); sentValues[i] = value; } } } I noticed the gateway sends the presentation of sensors all the time but that is not of much use in my setup. On the other hand it is useful to send the actual state periodically as it is known without remembering or if the controller started later than GW. But I have a feeling that I might misused the presentation function. Does any one know if this approach is ok by the "mysensors way"? Of course I welcome any suggestion for improvments Thanks