Categories

Arduino and DS1624 temperature sensor

The DS1624 consists of two separate functional units: a 256-byte nonvolatile E2 memory and a direct-to-digital temperature sensor.

The nonvolatile memory is made up of 256 bytes of E2 memory. This memory can be used to store any type of information the user wishes. These memory locations are accessed through the 2-wire serial bus.

The direct-to-digital temperature sensor allows the DS1624 to measure the ambient temperature and report the temperature in a 12-bit word with 0.0625°C resolution. The temperature sensor and its related registers are accessed through the 2-wire serial interface. Figure 1 in the full data sheet shows a block diagram of the DS1624.

Features

Reduces Component Count with Integrated Temperature Sensor and Nonvolatile E2 Memory
Measures Temperatures from -55°C to +125°C in 0.0625°C Increments
±0.5°C Accuracy from 0°C to 70°C
256 Bytes of E2 Memory for Storing Information Such as Frequency Compensation Coefficients
No External Components
Easy-to-Use 2-Wire Serial Interface
Temperature is Read as a 12-Bit Value (2-Byte Transfer)
Available in 8-Pin SO and DIP Packages

 

Connection

Module Arduino
VDD 5v
Gnd Gnd
SDA SDA – A4
SCL SCL – A5

 

Code

I downloaded and imported the following library – https://github.com/bluemurder/DS1624

This is the example so some of the hard graft has already been done for you

#include <DS1624.h>
 
// Sensor presents all address pins connected to ground
DS1624 ds1624(0x00);
 
void setup()
{ 
// Begin serial connection at 9600 baud
Serial.begin(9600);
}
 
void loop()
{
float temperature;
bool valid;
 
// Get current temperature
ds1624.GetTemperature(temperature, valid);
 
// Print it
Serial.println(temperature);
 
// Wait a while
delay(1000);
}

Testing

Open the serial monitor and you should see the following

24.31
24.31
24.87
25.94
26.44
27.06
27.37
27.81
27.81
27.69

 

Link

https://datasheets.maximintegrated.com/en/ds/DS1624.pdf

Share

DM11A88 8 x 8 LED matrix example

This was an 8×8 dot matrix module which is based on 74hc595, its reasonably easy to program and there is also a tool that allows you to create animations
Description :
Square matrix display module 8×8 dot
Red pixels
Pixel size: 3.0MM
74hc595 driver
Can display variety of patterns and characters

Connection

Arduino Connection Module Connection
5v Vcc
Gnd GND
D11 DI
D12 CLK
D8 LAT

Code

You need an animation header and also a couple of libraries but here is the main code – the zip file underneath has all you need
#include <TimerOne.h>
#include "animation.h"
 
//Pin connected to LAT of module
int latchPin = 8;
//Pin connected to CLK of module
int clockPin = 12;
////Pin connected to DI of module
int dataPin = 11;
 
// A number indicating when to advance to the next frame
unsigned long nextImage = 0;
int animationIndex = 0;
byte brightnesses[64];
int M[8];
//------------------------------------------------------------------------
 
void setup() {
  //set pins to output so you can control the shift register
  pinMode(latchPin, OUTPUT);
  pinMode(clockPin, OUTPUT);
  pinMode(dataPin, OUTPUT); 
}
 
void loop() {
  if(animationIndex >= animationFrames) 
  {
    //restart animation index
    animationIndex = 0;
  }
  else{
    //load Delay time for Image
    nextImage = animationDelays[animationIndex];
 
    //load image(converted)
    for(int i=0; i<64; i++) {
      brightnesses[i] = (animation[animationIndex][i/4] >> (i%4*2)) & B00000001;
      M[i/8] |= (brightnesses[i] << (i%8)) ;
    }
 
    //Update Image
    screenUpdate(nextImage);
    animationIndex ++;
 
    //clear M[]
    for(int i=0; i<(8); ++i) {
      M[i]=0;
    }
  }
 
}
 
 
void screenUpdate(unsigned long frametime) 
{ // function to display image
 
    unsigned long startime=millis();
  while(millis()-startime<frametime)
  {
    byte row = B10000000; // row 1 
    for (byte k = 0; k < 8; k++) 
    {
      digitalWrite(latchPin, LOW); // open latch ready to receive data
      shiftIt(~row); // row binary number
      shiftIt(M[k]); // LED array (inverted) 
 
      // Close the latch, sending the data in the registers out to the matrix
      digitalWrite(latchPin, HIGH);
      row = row>> 1; // bitshift right
    }
  } 
}
 
 
 
void shiftIt(byte dataOut) {
  // Shift out 8 bits LSB first, on rising edge of clock
  boolean pinState;
 
  //clear shift register read for sending data
  digitalWrite(dataPin, LOW);
  // for each bit in dataOut send out a bit
  for (int i=0; i<8; i++) {
    //set clockPin to LOW prior to sending bit
    digitalWrite(clockPin, LOW);
    // if the value of DataOut and (logical AND) a bitmask
    // are true, set pinState to 1 (HIGH)
    if ( dataOut & (1<<i) ) {
      pinState = HIGH;
    }
    else {
      pinState = LOW;
    }
    //sets dataPin to HIGH or LOW depending on pinState
    digitalWrite(dataPin, pinState);
    //send bit out on rising edge of clock
    digitalWrite(clockPin, HIGH);
    digitalWrite(dataPin, LOW);
  }
  digitalWrite(clockPin, LOW); //stop shifting
}

Video

What better way than a video of some of the examples

Links

I found the resources for this hard to find at first but here is a zip with the code example above, timerone library and also the animation jar file

88 Square Matrix LED

Buy one of them here

Share

A basic Simba OS example on an Arduino

Ok, I had heard of Simba OS but hadn’t managed to try it, as quoted “2Simba is an RTOS and build framework. It aims to make embedded programming easy and portable”

Install it

Install Simba in the Arduino IDE 1.6.10+ as a third party board using the Boards Manager.

Open File -> Preferences.

Add this URL to Additional Boards Manager URLs and press OK.

https://raw.githubusercontent.com/eerimoq/simba-releases/master/arduino/avr/package_simba_avr_index.json
Open Tools -> Board: … -> Boards Manager… and type simba in the search box.
Click on Simba by Erik Moqivst version x.y.z and click Install and press Close.
Open Tools -> Board: … -> Boards Manager… and select one of the Simba boards in the list.

Now my setup was slightly different, I had an Arduino Nano fitted to a NANo_UNO shield adaptor and a Easy Module Shield fitted to that as well, this was so I can get access to the many onbaord components on that shield via my Nano.

In this case basically we are using 2 LEDs connected to D12 and D13 and we will flash them on and off, so the schematic looks like this

 

Schematic

 

Code

#include "simba.h"
 
int main()
{
    struct pin_driver_t led1;
    struct pin_driver_t led2;
    /* Start the system. */
    sys_start();
 
    /* Initialize the LED pin as output and set its value to 1. */
    pin_init(&led1, &pin_d12_dev, PIN_OUTPUT);
    pin_init(&led2, &pin_d13_dev, PIN_OUTPUT);
    pin_write(&led1, 12);
    pin_write(&led2, 13);
    while (1) {
        /* Wait half a second. */
        thrd_sleep_ms(500);
        /* Toggle the LED on/off. */
        pin_toggle(&led1);
        thrd_sleep_ms(500);
        pin_toggle(&led2);
    }
 
    return (0);
}

 

Upload the sketch and all going well, flashy led’s. I like the look of Simba, it will be something that I play about with.

Share

ATmega328 and for ESP8266 Arduino board

RobotDyn UNO+WIFI R3  is a customized version of the classic ARDUINO UNO R3 board which has two Processors: Atmel ATmega328 microcontroller and ESP8266 WiFi chip with 8 MB flash memory. Each processor has its own pinout headers. The board also has USB-TTL converter based on CH340G on same board.

The convenient solution for the development of new projects requiring Uno and WiFi. Via USB you can update sketches and firmware for ATmega328 and for ESP8266. The board has DIP-switch, to connect the processors.

Features

  • Two CPUs: ATMEGA328P (8-Bit) and ESP8266 (32-Bit)
  • 8mb ESP8266 Flash Memory
  • External U.FL Antenna Connector for WiFi
  • Micro USB connection
  • Power jack, 7-12V power input.
  • Compatible with Arduino
  • Compatible with nodemcu
  • Can be used with existing Arduino Shields

 

Specifications

Microcontrollers 1x ATMEGA328P and 1x ESP-8266EX
Operating Voltage 5V for ATMEGA328P and 3.3V for ESP8266
Digital I/O Pins 13 for ATMEGA328P (5v compliant)+ 8 for ESP8266 (3.3V compliant)
Analog Input Pins 6 for ATMEGA328P (5V compliant) + 1 for ESP8266 (3.3V compliant)
Clock Speed 16MHz for ATMEGA328P and 80MHz/160MHz for ESP8266
ESP8266 Flash 8M bytes

 

The key for operation is the dip switches, here are the combinations

 

Connection

DIP

1

2

3

4

5

6

7

ATmega328<->ESP8266

ON

ON

OFF

OFF

OFF

OFF

OFF

USB <->ATmega328

OFF

OFF

ON

ON

OFF

OFF

OFF

USB<->ESP8266 (Update firmware or sketch)

OFF

OFF

OFF

OFF

ON

ON

ON

USB<->ESP8266 (communication)

OFF

OFF

OFF

OFF

ON

ON

OFF

All independent

OFF

OFF

OFF

OFF

OFF

OFF

OFF

Initially I had difficulty uploading a sketch but these settings work with regards the dip switch, I selected an Arduin/Genuino Uno

CH340 connect to ATmega328 (upload sketch) OFF OFF ON ON OFF OFF OFF NoUSE

Code

This was a modified version of the blink sketch, only difference is that I had an LED connected to D6

void setup() 
{
  pinMode(6, OUTPUT);
}
 
// the loop function runs over and over again forever
void loop() 
{
  digitalWrite(6, HIGH);   // turn the LED on (HIGH is the voltage level)
  delay(1000);                       // wait for a second
  digitalWrite(6, LOW);    // turn the LED off by making the voltage LOW
  delay(1000);                       // wait for a second
}

 

Links

http://robotdyn.com/downloads/comp_docs/CH340/CH341SER.ZIP

http://robotdyn.com/downloads/comp_docs/CH340/CH340_driver_instruction.pdf

PINOUT=UNO+WiFi-R3-AT328-ESP8266-CH340G.pdf

 

Purchase

UNO+WiFi R3 ATmega328P+ESP8266 (32Mb memory), USB-TTL CH340G. Compatible for Arduino Uno, NodeMCU, WeMos ESP8266

Share