[IDEA] Monitor Tap List at Bar

@austinpe, what is the longest distance from the Spark to the last keg? One possible solution is to use 1-wire eeproms (Maxim) where each have a unique serial number to identify them. With 1-wire you can power AND read the data with just two wires (data/power, gnd). You would put one on each keg with a set of contacts like @Hypnopompia suggested. That way ALL devices can be “discovered” over 2 wires! :smile:

2 Likes

@peekay123
I was in the MIDDLE of editing my last post! I just found some 1wire stuff.
Here’s my edit:

1wire! I have found both the iButton and the DS2431 EEPROM. I’m going to go with the DS2431 for now as it’s cheaper and expandable for other possible uses.

Here are some useful resources I’ve found on it/1-wire thus far:
http://hackaday.com/2008/12/24/parts-1k-1-wire-eeprom-ds2431
http://tushev.org/articles/arduino/item/50-reading-ibutton-with-arduino
http://www.hacktronics.com/Tutorials/arduino-1-wire-tutorial.html
http://playground.arduino.cc/Learning/OneWire

There seems to be some arduino libraries already available, so I was hoping that @peekay123 could point me to some resources to porting arduino -> spark.

1 Like

@austinpe, porting is a lot like black magic and it’s not easy to describe. If you find a good arduino library, I’ll gladly port it for you. I remember reading a topic about using multiple 18B20 temperature sensors and having code to “discover” them. There could be some good info there. :smile:

It’s not “black magic”. Magic isn’t real. Porting is more of trial-error-bang-head-on-keyboard-to-continue-lather-rinse-repeat.

2 Likes

@wgbartley That’s what he said. Magic. :slight_smile:

Here is the thread that @peekay123 mentioned:

The Spark is working on an “official” one-wire library, but Dave from Spark has this in a gist while they are working on it.

2 Likes

@wgbartley, you forgot the slay-the-chicken-wait-for-an-eclipse-cross-your-fingers-and-hope-the-stars-align part! :wink:

2 Likes

@Hypnopompia’s resistor idea sounds pretty doable to me. This is a great idea for accomplishing the goal on the cheap.You could use a multiplexer to handle readings from many sources using few pins on the :spark:, for example, this breakout board:

Analog/Digital MUX Breakout

With a couple of those, you could read up to 32 sources, while using only 5 control pins for addressing. You’d just need a little work to select between one breakout board or the other, but it should be simple enough.

2 Likes

@dougal, that is an excellent suggestion! I believe the biggest challenge regardless of which identification “device” is used will be wire length that causes voltage drop, noise, capacitance and slew rate issues, especially at 3.3V.

2 Likes

@dougal - I like that idea! I have already ordered and recieved the OneWIre eeproms though, so we’ll see if I can get those to work…


Alright, I got the my EEPROMs in …

Using a combination of:


http://playground.arduino.cc/Learning/OneWire

and the code on the last post of here:
http://forum.arduino.cc/index.php/topic,18198.0.html

I attempted to read the device serial on my arduino… to no avail :frowning:

I have the DS2431 pin 1 going to ground, pin 2 going to arduino ds(2) with a 2.2k (I also tried 4.7k) pull-up to 5v

I keep receiving a “No Device Found” returned in the Serial feedback

Reading the arduino page on the matter, apparently there is both parasitic power and normal power mode. Normalrequires the 5v pin and parasite just uses the digital pin … I’ve tried both configurations.

@peekay123 – would it be too much to ask to see if you could take a look at the code in that second link and see if it’s spark-portable. Maybe I might have more luck on the spark platform? The library seems to have read/read of the eeprom included, which is great!

edit: after trying three different sketches on the arduino, the issue is definitely that the eeprom is not being found by the arduino when the “ds.search(addr)” returns nothing. I’m really not sure what this command does…

@austinpe, which arduino are you using and which version of the IDE?

You need to be using the lastest OneWire library and in the code listed on the arduino forum, I would change all “byte” types to “uint8_t”. Then give it a shot. :smile:

@peekay123 I have an arduino uno. I’m not sure which revision, but it’s probably a few years old. I had to dig it up from an old project from at least 2 years ago. As for the IDE, I’m using 1.0.5-r2.

I loaded the library you linked to and have the code from that forum post.

I tried it both with byte and with uint8_t (I just replaced every instance of byte with uint8_t) and I still get “no device found”…

Should I be using the 5v pin to drive it, or just use the digital pin to power the device? I guess I may want to try the 3.3v pin. According to the datasheet it’s tolerate from 2.8V to 5.25V …so I don’t think I’ve fried them or anything.

Also, I’m not sure what value of pull-up resistor I need as some sources were saying 4.7k and some were saying 2.2k

Thoughts?

edit: When I check the voltage drop across pin1 and pin2 of the DS2431 I get 0v when I do not have pin2 (IOpin) connected to a voltage source, even when the arduino is actively looking for a device. But, even when there is voltage, I still get “no device found”

@austinpe, I always have an arduino handy to test stuff :wink: I would power the device with 5V to start with and use a 2.2K pull-up as they suggest a “strong” pull-up. This is because the pull-up voltage AND the I/O pin voltage must be the same. So going to 3.3V for pull-up will not work on the arduino but would be ok on the Spark since I/O and pull-up would be 3.3V.

The DS2431 is powered via its data pin, oddly enough! So the pull-up also supplies power. Change the setup() in the code to this:

void setup(void)
{
  Serial.begin(9600);
  while (!Serial.available());
  boolean present = ds.reset();
  
  Serial.print("1-wire device present: ");
  Serial.println(present);
  while(1);
}

The ds.reset() should return a 1/TRUE if a device is found on the bus. Notice that I added code that requires you to hit any key on the serial console for setup() to continue to give you time to start the console. Run that and see what you get. :smile:

@peekay123 I get a “1-wire device present: 0” … I’m obviously doing something wrong!

Here’s my RS2431 Fritzing sketch to see if I have it setup wrong! The sketch shows the UNO R3, but I looked and have the UNO R2, do you think that would make any difference? (I wouldn’t think so.)

Also, the sketch shoes a PNP transistor… but that’s only because there wasn’t a RS2431 readily available. But, it’s the same shape, so hopefully it makes sense.

@austinpe, the differences between the R2 and R3 should not have any affect on this test. The diagram looks fine. So it could be the code or the device. I’m at a bit of a loss. You could get a Bus Pirate to do the testing. Without having one of these, I’m stuck :frowning:

If you have a DS18B20 temperature sensor, you could test the 1-wire library with that to at least make sure the UNO stuff works. A simple DS18B20 demo is located here.

@peekay123 – I don’t have a bus pirate or a DS18B20 sensor :cry:

Do you think it’d be worth trying it on the spark?

I guess I can order a DS18B20 as well as the MUX breakout board that @dougal was talking about.

Bummer.

So, I got desperate and tried EVERY combination of pins to ground/IO and … it worked!
The documentation shows:

I thought that the “side view” was really a top down view, but it’s really a bottom-up view (as if the pins are pointing towards you) :blush:

I feel pretty dumb :frowning:

so @peekay123 , now that I got it to work on arduino… wanna practice some of your magic on a port when you get some time (I’ll try my own port, too, just so I don’t put you out) :smiley: :stuck_out_tongue:

@austinpe, don’t feel dumb, I did the same thing!!! Showing “side view” is the dumbest thing I have ever seen. Problem is, I have seen this type of view so many times, I KNOW it’s bottom view. But NOooo, today I fell for it! LOL :stuck_out_tongue:

Ok, so now that it’s working, I will look at the rest of the library :smile:

UPDATE: Before I proceed, the easiest way to identify each unique DS2431 is by its serial number. No need to write anything to the eeprom! Is this the way you want to proceed?

1 Like

@peekay123 yes, I th ink that is the best way to go about it as well.

We are not dealing with a very large distance (4-5 feet max wire length… if even).

The idea I was having would be do just do a database of the serial numbers for each EEPROM. Then I could just easily update it in the database instead of having to write the data to the device.

So, this is the only code that would be used.
I just uploaded this sketch to my arduino and tested it, and it comes back with JUST the address of the EEPROM.

#include <OneWire.h>

OneWire  ds(2);    // 1-wire on pin 2
byte     addr[8];  // Contains the eeprom unique ID
void setup(void)
{
  Serial.begin(9600);
}
  
void loop(void) 
{
  byte i;
  byte dat[13];

  SearchAddress(addr);
  
  while(1);
}

void SearchAddress(byte* address) //Search for address and confirm it
{
  int i;
  if ( !ds.search(address))
  {
    Serial.print("No device found.\n");
    ds.reset_search();
    delay(250);
    return;
  }
  
  Serial.print("ADDR= ");
  for( i = 0; i < 8; i++)
  {
    Serial.print(address[i], HEX);
    Serial.print(" ");
  }

  if ( OneWire::crc8( address, 7) != address[7])
  {
      Serial.print("CRC is not valid, address is corrupted\n");
      return;
  }
  
  if ( address[0] != 0x2D) 
  {
      Serial.print("Device is not a 1-wire Eeprom.\n");
      return;
  }
  Serial.println();
}

edit
It’s interesting that if I have multiple DS2431 chained together, it will only read ONE of them.
If I then add another call of “SearchAddress(addr)”, then it’ll show two devices, etc.
But, it shows the “last” DS2431 (the one connected furthered right) in the chain FIRST.

I’ll have to edit the code to search for however many devices there are.

1 Like