sketchbook
 All Classes Namespaces Files Functions Variables Typedefs Enumerations Enumerator Macros Groups Pages
Macros | Functions | Variables
DeviceGeneric.ino File Reference

Example-Code for a generic Device (e.g. Sensor, Display) More...

#include <PJON.h>

Macros

#define TEMP_OFFSET   -309.00
 
#define TEMP_COEFF   1.22
 
#define SENSOR   "owp:dg:v1"
 
#define OWPJONID   44
 
#define OWPJONPIN   12
 
#define READ_INFO   0x01
 
#define READ_VCC   0x11
 
#define READ_TEMP   0x12
 
#define READ   0x21
 
#define WRITE   0x22
 
#define WRITE_CAL   0x32
 

Functions

PJON< SoftwareBitBang > bus (OWPJONID)
 
void setup ()
 
void receiver_function (uint8_t *payload, uint16_t length, const PJON_Packet_Info &packet_info)
 
void loop ()
 
float readVcc ()
 
float readTemp (void)
 

Variables

uint8_t mem_buffer [256]
 

Detailed Description

Example-Code for a generic Device (e.g. Sensor, Display)

Example-Code for a Nano Sensor Station (SEN02281P, MIC, GUVA-S12SD, TSL2561, BME280) (optionally AS7265X)

Author
drtrigon
Date
2018-07-06
Version
1.0
  • first version derived from PJON 11.0 examples examples/ARDUINO/Local/SoftwareBitBang/BlinkWithResponse/Receiver/Receiver.ino
OWPJON/ARDUINO/Local/SoftwareBitBang/BlinkWithResponse/Receiver/Receiver.ino
See Also
https://github.com/gioblu/PJON/blob/master/examples/ARDUINO/Local/SoftwareBitBang/BlinkWithResponse/Receiver/Receiver.ino
* OneWire PJON Generic "OWPG" scheme:
*   Server e.g. linux machine or raspi
*      OWPJON/LINUX/Local/LocalUDP/RemoteWorker/DeviceGeneric/
*      OWPJON/LINUX/Local/ThroughSerial/RemoteWorker/DeviceGeneric/
*   Tunnel(er) similar to 1wire master (similar cause we are on a multi-master bus) e.g. AVR
*      OWPJON/ARDUINO/Local/SoftwareBitBang/Tunneler/BlinkingSwitch/
*      OWPJON/ARDUINO/Local/SoftwareBitBang/Tunneler/BlinkingSwitch_SWBB-TS/
*      OWPJON/ARDUINO/Local/ThroughSerial/SoftwareBitBangSurrogate/Surrogate/ (obsolete)
*   Devices e.g. AVR
*      OWPJON/ARDUINO/Local/SoftwareBitBang/DeviceGeneric/ (this sketch)
*      OWPJON/ARDUINO/Local/SoftwareBitBang/OWP_DG_LCD_Sensors/
*      ...
*
* Compatible with: atmega328 (Uno, Nano), atmega32u4 (Yun)
*   ID 42: Nano Test Device on outdoor SWBB bus (testing)
*   ID 44: Nano Test Device on indoor SWBB bus (productive; collectd)
*
* Pinout:
*   1wire PJON data bus (OWPJON SWBB):
*        1WIRE DATA    -> Arduino Pin D12
*        GND black     -> Arduino GND
*
* Test on Ubuntu or Raspberry Pi Server (owpshell) confer the docu of
* following files:
*   - @ref OWPJON/LINUX/Local/LocalUDP/RemoteWorker/DeviceGeneric/DeviceGeneric.cpp
*   - @ref OWPJON/LINUX/Local/ThroughSerial/RemoteWorker/DeviceGeneric/DeviceGeneric.cpp
*
* Thanks to:
* gioblu - PJON 11.0 and support
*          @see https://www.pjon.org/
*          @see https://github.com/gioblu/PJON
* fredilarsen - support
* 
Author
drtrigon
Date
2018-07-06
Version
1.0 OWPJON/ARDUINO/Local/SoftwareBitBang/DeviceGeneric/DeviceGeneric.ino Uno_OWSlave/OWH_DS18B20_asInterface_SensorStation/OWH_DS18B20_asInterface_SensorStation.ino
* OneWire PJON Generic "OWPG" scheme:
*   Server e.g. linux machine or raspi
*      OWPJON/LINUX/Local/LocalUDP/RemoteWorker/DeviceGeneric/
*      OWPJON/LINUX/Local/ThroughSerial/RemoteWorker/DeviceGeneric/
*   Tunnel(er) similar to 1wire master (similar cause we are on a multi-master bus) e.g. AVR
*      OWPJON/ARDUINO/Local/SoftwareBitBang/Tunneler/BlinkingSwitch/
*      OWPJON/ARDUINO/Local/SoftwareBitBang/Tunneler/BlinkingSwitch_SWBB-TS/
*      OWPJON/ARDUINO/Local/ThroughSerial/SoftwareBitBangSurrogate/Surrogate/ (obsolete)
*   Devices e.g. AVR
*      OWPJON/ARDUINO/Local/SoftwareBitBang/DeviceGeneric/ (this sketch)
*      OWPJON/ARDUINO/Local/SoftwareBitBang/OWP_DG_LCD_Sensors/
*      ...
*
* Compatible with: atmega328 (Uno, Nano), atmega32u4 (Yun)
*   ID 42: Nano Test Device on outdoor SWBB bus (testing)
*   ID 44: Nano Test Device on indoor SWBB bus (productive; collectd)
*
* Pinout:
*   1wire PJON data bus (OWPJON SWBB):
*        1WIRE DATA    -> Arduino Pin D8
*        GND black     -> Arduino GND
*
* Test on Ubuntu or Raspberry Pi Server (owpshell) confer the docu of
* following files:
*   - @ref OWPJON/LINUX/Local/LocalUDP/RemoteWorker/DeviceGeneric/DeviceGeneric.cpp
*   - @ref OWPJON/LINUX/Local/ThroughSerial/RemoteWorker/DeviceGeneric/DeviceGeneric.cpp
*   - use ThroughSerial testing like:
*     $ printf "\x01" | ./owpshell-ubuntu14.04 /dev/ttyUSB0 9600 40
*     owp:ss:v1
*     $ printf "\x53" | ./owpshell-ubuntu14.04 /dev/ttyUSB0 9600 40 | python unpack.py f
*     970.3897094726562,
*
* Thanks to:
* gioblu - PJON 11.0 and support
*          @see https://www.pjon.org/
*          @see https://github.com/gioblu/PJON
* fredilarsen - support
* 

Macro Definition Documentation

#define OWPJONID   44
#define OWPJONPIN   12
#define READ   0x21
#define READ_INFO   0x01
#define READ_TEMP   0x12
#define READ_VCC   0x11
#define SENSOR   "owp:dg:v1"
#define TEMP_COEFF   1.22
#define TEMP_OFFSET   -309.00
#define WRITE   0x22
#define WRITE_CAL   0x32

Function Documentation

PJON<SoftwareBitBang> bus ( OWPJONID  )
void loop ( void  )

OneWirePJON device status update function.

Returns
(void)
float readTemp ( void  )

Internal Temperature Sensor for ATmega328 types.

Parameters
void
See Also
receiver_function()
https://playground.arduino.cc/Main/InternalTemperatureSensor
Returns
The chip temperature in [°C]
float readVcc ( )

Accessing the secret voltmeter on the Arduino 168 or 328.

See Also
receiver_function()
http://code.google.com/p/tinkerit/wiki/SecretVoltmeter
Returns
The supply voltage in [V]
void receiver_function ( uint8_t *  payload,
uint16_t  length,
const PJON_Packet_Info &  packet_info 
)
void setup ( void  )

Arduino IDE: put your setup code here, to run once.

Variable Documentation

uint8_t mem_buffer[256]