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

Example-Code for Adaptor Device to connect Dallas/Maxim DS2438 and DS18x20 1wire Slaves. More...

#include <OneWire.h>
#include <DS2438.h>
#include <PJON.h>

Macros

#define SENSOR   "owp:1w:v1"
 
#define OWPJONID   42
 
#define OWPJONPIN   4
 
#define ONE_WIRE_PIN   2
 
#define _LED_BUILTIN   8
 
#define READ_INFO   0x01
 
#define READ_VCC   0x11
 
#define READ_TEMP   0x12
 
#define READ   0x21
 
#define WRITE   0x22
 
#define WRITE_CAL   0x32
 
#define READ_DS2438_TEMP   0x41
 
#define READ_DS2438_CHA   0x42
 
#define READ_DS2438_CHB   0x43
 
#define READ_DS18x20_TEMP   0x44
 
#define READ_DS2438_ROM   0x4A
 
#define READ_DS18x20_ROM   0x4B
 

Functions

OneWire ow (ONE_WIRE_PIN)
 
PJON< SoftwareBitBang > bus (OWPJONID)
 
bool discoverOneWireDevices (const OneWire &ds, const uint8_t family=NULL)
 
void setup ()
 
void receiver_function (uint8_t *payload, uint16_t length, const PJON_Packet_Info &packet_info)
 
void loop ()
 
float readVcc ()
 
float readTemp (void)
 
float readDS18x20 (const OneWire ds, const byte addr[])
 

Variables

uint8_t mem_buffer [256]
 
byte addr [8]
 
bool DS2438_ENABLE = false
 
byte DS2438_addr [8]
 
bool DS18x20_ENABLE = false
 
byte DS18x20_addr [8]
 
DS2438 ds2438ow
 

Detailed Description

Example-Code for Adaptor Device to connect Dallas/Maxim DS2438 and DS18x20 1wire Slaves.

Author
drtrigon
Date
2018-08-02
Version
1.0 OWPJON/ARDUINO/Local/SoftwareBitBang/DeviceGeneric/DeviceGeneric.ino
See Also
https://playground.arduino.cc/Learning/OneWire
https://github.com/jbechter/arduino-onewire-DS2438/blob/master/examples/DS2438TemperatureAndVoltage/DS2438TemperatureAndVoltage.ino
https://cdn.shopify.com/s/files/1/0164/3524/files/MultiSensor_Manual_v1.5.pdf?15845834050373852166
* OneWire PJON Generic "OWPG" scheme:
*   @ref OWPJON/LINUX/Local/LocalUDP/RemoteWorker/DeviceGeneric/DeviceGeneric.cpp
*
* Compatible with: atmega328 (Uno, Nano), atmega32u4 (Yun)
*   ID 42: Nano Test Device on outdoor SWBB bus (testing)
*
* Pinout (Uno, Nano):
*   1wire PJON data bus (OWPJON SWBB):
*        1WIRE DATA    -> Arduino Pin D12
*        GND black     -> Arduino GND
*   1wire Dallas/Maxim data bus (MicroLAN):
*        1WIRE DATA    -> Arduino Pin D2
*   A 4.7k pull-up resistor must be connected to the 1-wire bus (Pin D2).
*   Needs a weak pull-up (that the uP cannot provide).
*
* Example sending READ_DS... commands to device id 42:
* $ printf "\x4A" | ./owpshell - - 42 | ../../../ThroughSerial/RemoteWorker/DeviceGeneric/unpack.py BBBBBBBB
* 38, 0, 0, 215, 1, 0, 0, 77
* $ printf "\x4B" | ./owpshell - - 42 | ../../../ThroughSerial/RemoteWorker/DeviceGeneric/unpack.py BBBBBBBB
* 40, 66, 243, 63, 5, 0, 0, 10
* $ printf "\x41" | ./owpshell - - 42 | ../../../ThroughSerial/RemoteWorker/DeviceGeneric/unpack.py f
* 23.03125,
* $ printf "\x42" | ./owpshell - - 42 | ../../../ThroughSerial/RemoteWorker/DeviceGeneric/unpack.py f
* 1.690000057220459,
* $ printf "\x43" | ./owpshell - - 42 | ../../../ThroughSerial/RemoteWorker/DeviceGeneric/unpack.py f
* 4.590000152587891,
* $ printf "\x44" | ./owpshell - - 42 | ../../../ThroughSerial/RemoteWorker/DeviceGeneric/unpack.py f
* 27.125,
* More info can be found in @ref OWPJON/README.md. Confer also the docu of
* following files for info about tests on Ubuntu or Raspberry Pi Server (owpshell):
*   - @ref OWPJON/LINUX/Local/LocalUDP/RemoteWorker/DeviceGeneric/DeviceGeneric.cpp
*   - @ref OWPJON/LINUX/Local/ThroughSerial/RemoteWorker/DeviceGeneric/DeviceGeneric.cpp
*
* Using on (minimal/raw) atmega328 w. 16MHz oscil.
*   use Uno with ArduinoISP Example and "Arduino as ISP"
*   connect (like attiny85) for ISP (SPI) programming, see e.g.
*     http://www.gammon.com.au/breadboard
*     https://github.com/nickgammon/arduino_sketches
*     (for debugging see "Chip not detected", "Alternate clock source")
*   select "Arduino/Genuino Uno" board and Tools > Burn Bootloader
*   then compile and upload sketch with (Upload button doesn't work)
*     Sketch > Upload Using Programmer
*
* 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 _LED_BUILTIN   8
#define ONE_WIRE_PIN   2
#define OWPJONID   42
#define OWPJONPIN   4
#define READ   0x21
#define READ_DS18x20_ROM   0x4B
#define READ_DS18x20_TEMP   0x44
#define READ_DS2438_CHA   0x42
#define READ_DS2438_CHB   0x43
#define READ_DS2438_ROM   0x4A
#define READ_DS2438_TEMP   0x41
#define READ_INFO   0x01
#define READ_TEMP   0x12
#define READ_VCC   0x11
#define SENSOR   "owp:1w:v1"
#define WRITE   0x22
#define WRITE_CAL   0x32

Function Documentation

PJON<SoftwareBitBang> bus ( OWPJONID  )
bool discoverOneWireDevices ( const OneWire &  ds,
const uint8_t  family = NULL 
)
void loop ( void  )

OneWirePJON device status update function.

Returns
(void)
OneWire ow ( ONE_WIRE_PIN  )
float readDS18x20 ( const OneWire  ds,
const byte  addr[] 
)
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

byte addr[8]
byte DS18x20_addr[8]
bool DS18x20_ENABLE = false
byte DS2438_addr[8]
bool DS2438_ENABLE = false
uint8_t mem_buffer[256]
DS2438 ds2438& ow