Spark compatibility library for known tested sensors/devices?

The theme of the thread has changed a little. It appears whilst we don’t have a dedicated working device library yet… The following might help. I’ll try and keep it up to date as people post more below or I find them in other threads.

Stepper Motor Library Port: https://gist.github.com/technobly/8341919

Temperature Dilution Filter: https://gist.github.com/technobly/8342009

Remote RTTTL (RingTone Text Transfer Language) Song Player: https://github.com/technobly/Remote-RTTTL

Simple Tone Generator: https://gist.github.com/technobly/8342067

A Remote Starter example that’s a customize-able simple Spark Core web app controller with feedback through Variables: https://github.com/technobly/Remote-Spark1

Simple Spark Core Controller: https://github.com/technobly/Simple-Spark-Core-Controller1

LiquidCrystal Library: https://gist.github.com/technobly/8342145

Custom PWM Frequency: https://gist.github.com/technobly/8313449

Simple Bit-Bang (Direct Port Manipulation): https://gist.github.com/technobly/8342185

BMP085/BMP180 Barometric Pressure + Temp sensor: https://gist.github.com/technobly/83423291

Adafruit WS2812 NeoPixel Library: https://github.com/technobly/SparkCore-NeoPixel

Intro to Inline Assembly on the Spark Core #1: https://gist.github.com/technobly/8342185

DHT11 Temp/Humidity Sensor: https://community.spark.io/t/dht22-dht11-and-similar-blocking-version/998

(verified) Adafruit WS2801 Library: https://gist.github.com/technobly/83395483

(verified) MCP23008 I2C / SPI LCD BACKPACK: https://gist.github.com/technobly/84588084

(verified) Fast Read Example (Digital Input): https://gist.github.com/technobly/8573877

(verified) HARDWARE / SOFTWARE LIQUIDCRYSTAL SPI 74HC595 LIBRARY:

3 Likes

I’ll kick us off then…

DHT11 Temp/Humidity Sensor link: working

SHT21 Temp/Humidity Sensor, I2C interface: I will attempt to adapt the Arduino library and report back.

Paul

1 Like

We could link them all in here, but ultimately this thread will get lost. Maybe Spark can host a Wiki page for user examples? Even if we just add links to our Github, Pastebin, Blog etc… locations… or spend the time to add it all in a user’s Wiki page.

Brainstorming with Carl Danley, we’re thinking just a dedicated section in the Spark Forums would be perfect for WIP, and FINAL code examples. We are kind of doing it already, and they are going into the Libraries and Projects sections mostly… but small code examples might be better found in a section called Snippets. Not really a full project, or library… just a short code snippet.

Maybe we could sticky a post to the top of the Snippets section that encourages users to post their code on Github, Pastebin, in a Gist or just in the post itself (and explain how to format it nicely with CTRL+K), and include whether or not the code is tested and working, or what limitations remain… and what is left TODO.

1 Like

This also gives us a place for those users who’ve posted to talk about improvements to the snippet and so on. I think it’s a great way to organize code and give us a spot to post cool snippets. +1 for this idea BDub!

1 Like

And +1 again… Ideally a simple table with the device linking to Github… Otherwise it’s all going to get too complicated.

Dom, how about for now we drop a bunch of links in here and you manage editing the first post with a nice list of links? They can be Formatted Links too… would keep it nice and neat.

Sure… That’ll work.

Edited my post above… apparently the Formatted Links thing didn’t work the first time I tried… I was probably moving too fast and didn’t preview it.

Ok here comes my list:

(verified) Stepper Motor Library Port: https://gist.github.com/technobly/8341919

(verified) Temperature Dilution Filter: https://gist.github.com/technobly/8342009

(verified) Remote RTTTL (RingTone Text Transfer Language) Song Player: https://github.com/technobly/Remote-RTTTL

(verified) Simple Tone Generator: https://gist.github.com/technobly/8342067

(verified) A Remote Starter example that’s a customize-able simple Spark Core web app controller with feedback through Variables: https://github.com/technobly/Remote-Spark

(verified) Simple Spark Core Controller: https://github.com/technobly/Simple-Spark-Core-Controller

(verified) LiquidCrystal Library: https://gist.github.com/technobly/8342145

(verified) Custom PWM Frequency: https://gist.github.com/technobly/8313449

(verified) Simple Bit-Bang (Direct Port Manipulation): https://gist.github.com/technobly/8342185

(verified) BMP085/BMP180 Barometric Pressure + Temp sensor: https://gist.github.com/technobly/8342329

(verified) Adafruit WS2801 Library: https://gist.github.com/technobly/8339548

(verified) Adafruit WS2812 NeoPixel Library: https://github.com/technobly/SparkCore-NeoPixel

(verified) Intro to Inline Assembly on the Spark Core #1: https://gist.github.com/technobly/8342185

2 Likes

SHT21 i2c Temperature & Humidity Sensor: https://gist.github.com/PaulRB/8372742

Porting the Arduino library by Christopher Ladden was dead easy. I commented out the Wire.h and Arduino.h includes and changed the i2c address from 0x40 to 0x80 (because of the 7-bit/8-bit address issue, this will need to be changed back once that issue is resolved).

Note that this is a blocking/synchronous library. A non-blocking version should be possible. Tested with SHT21 but SHT25 should also be compatible.

Sample outputs: Humidity:

{
  "cmd": "VarReturn",
  "name": "humid",
  "TEMPORARY_allTypes": {
    "string": "39.1%",
    "uint32": 859385393,
    "number": 859385393,
    "double": null,
    "float": 4.31156799152177e-8,
    "raw": "39.1%"
  },
  "result": "39.1%",
  "coreInfo": {
    "last_app": "",
    "last_heard": "2014-01-11T16:15:40.212Z",
    "connected": true,
    "deviceID": "48ff70065067555042522387"
  }
}

Temperature:

{
  "cmd": "VarReturn",
  "name": "temp2",
  "TEMPORARY_allTypes": {
    "string": "20.2C",
    "uint32": 842018354,
    "number": 842018354,
    "double": null,
    "float": 1.0255051918761637e-8,
    "raw": "20.2C"
  },
  "result": "20.2C",
  "coreInfo": {
    "last_app": "",
    "last_heard": "2014-01-11T16:16:29.395Z",
    "connected": true,
    "deviceID": "48ff70065067555042522387"
  }
}

2 Likes

Hi @BDub, I can confirm your Gist code does work! Sample output:

Temperature = 21.58 *C
Pressure = 98376 Pa
Altitude = 248.73 meters
Real altitude = 262.69 meters

1 Like

That’s GREAT! Thanks a lot @PaulRB :smile:

1 Like

This is great guys! Thanks again @BDub :smile:

We’ll chat about some great ways to get links on our https://www.spark.io/resources page.

Hi @Steph, are you aware of a problem with this forum at the moment? I can post replies but can’t start new topics. I get the message:

Unknown error saving post, try again. Error: 500 Internal Server Error

Also my user profile won’t open, but everyone else’s do.

@PaulRB and @BDub we’re seeing a couple of problems since yesterday’s update but are actively working on it. We’ll keep you posted!

(verified) RTC DS1307 Library: https://gist.github.com/technobly/8387151

Take note of this:
#define DS1307_ADDRESS 0xD0 // Switch back to 0x68 when I2C 7-bit addressing is fixed

Pinouts on line 254 for DS1307 and Spark Core :spark:

Have fun!

Now Verified:

(verified) Adafruit WS2801 Library: https://gist.github.com/technobly/8339548

(verified) MCP23008 I2C / SPI LCD BACKPACK: https://gist.github.com/technobly/8458808

Verified:

(verified) HARDWARE / SOFTWARE LIQUIDCRYSTAL SPI 74HC595 LIBRARY:

@Dom please update this one, and also WS2801 is verified :wink: Thanks!

This line should be deleted: