Atlas Scientific Ardiuno to Particle code issues

i see the serial exapnder being used with the PWR-ISO in one of the block diagrams. It says that’s the one they used for the Tentacle. But the tentacle supports 12C. I don’t really want to use the tentacle and want to try the individual modules on a bread board first. That being said i have a display connected to the RX and TX and dont have any more serial left. Do not want to use the RGB workaround. Is there a way to use the serial expander with 12C?

@Ali The larger Tentacle shield has options for UART and i2c the smaller one is 12c only.

Has anybody had any success with the smaller i2c Tentacle Shield paired with the Particle shield shield? Just wouldn’t work for me, wasn’t getting any data back on i2c.

I went back to breadboards for testing.

@erkele I’m actually building a hydroponic control system for a client. Which is why I didn’t share all my code. That and it’s just initial test code not doing much yet. I’m keen to be helpful and generally always share my code but in this case have to be carefull of my clients IP.

I can see that there are a few of us working on similar projects and i’ll be as helpful as I can as i’m also benefiting from the community knowledge shared so far.

Anyway fun project i’m almost at the fun liquids and graphs part…

1 Like

Hey MrOmatic,

I hope they are growing something delcious!

No worries I completly understand, great to meet you though.

I working on monitoring water with various communications. As well I am making a few new sensors and for aquaculture such as measuring algae concentrations and potentially different types in real time.

I used to grow algae at large scale, so feel free to ask any questions if you want.

Cheers,

Erkele

For testing purposes I want to build all 4 sensors on a breadboard and use the pwr iso to get rid of interference. I just can figure out how to use 12c to connect all of them as all the block illustration show serial interfaces.

Hi @erkele!
I thought I’d show some code that uses the Electron’s UART ports rather than its I2C ports.

This code gets a value from each sensor every 60 seconds, and keeps querying the sensor until it receives a reasonable response (e.g. a pH value between 0 and 14).

#include "application.h"
#include "Serial4/Serial4.h"
#include "Serial5/Serial5.h"

#define pHSerial Serial1
#define ORPSerial Serial4
#define ECSerial Serial5

unsigned int intStartSequence = 0;

unsigned long elapsedTime = 0;
unsigned long startTime = 0;
unsigned long oldTime = 0;

String pHsensorstring = "";
float pHvalue;

String ORPsensorstring = "";
float ORPvalue;

String ECsensorstring = "";
char ECarray[30];
char *EC;
float ECvalue;

char *TDS;
float TDSvalue;

char *SAL;
float SALvalue;

char *SG;
float SGvalue;

void setup() {
  Serial.begin(9600);
  pHSerial.begin(9600);
  ORPSerial.begin(9600);
  ECSerial.begin(9600);
  pHsensorstring.reserve(30);
  ORPsensorstring.reserve(30);
  ECsensorstring.reserve(30);
}

void startSequence(void){
    //Turn off LEDs
    pHSerial.print("L,0");
    delay(100);
    ORPSerial.print("L,0");
    delay(100);
    ECSerial.print("L,0");
    delay(100);
    //Turn off continuous sampling
    pHSerial.print("C,0");
    delay(100);
    ORPSerial.print("C,0");
    delay(100);
    ECSerial.print("C,0");
    delay(100);
}

void getpHdata(void){
    pHSerial.flush();
    pHSerial.print("r\r");
    delay(100);
    pHsensorstring = pHSerial.readStringUntil('\r');
    pHvalue = atof(pHsensorstring);
}

void getORPdata(void){
    ORPSerial.flush();
    Serial4.print("r\r");
    delay(100);
    ORPsensorstring = ORPSerial.readStringUntil('\r');
    ORPvalue = atof(ORPsensorstring);
}

void getECdata(void){
    ECSerial.flush();
    ECSerial.print('r\r');
    delay(500);
    ECsensorstring = ECSerial.readStringUntil('\r');
    printECdata();
}

void printECdata(void){
    ECsensorstring.toCharArray(ECarray, 30);
    EC = strtok(ECarray, ",");
    ECvalue = atof(EC);
    TDS = strtok(NULL, ",");
    TDSvalue = atof(TDS);
    SAL = strtok(NULL, ",");
    SALvalue = atof(SAL);
    SG = strtok(NULL, ",");
    SGvalue = atof(SG);
}

void loop() {
    if (millis() - oldTime >= 60000){ 
        startTime = millis();
        if (intStartSequence == 0){
            //startSequence();
            intStartSequence = 1;
        }
        
        getpHdata();
        while(!(isdigit(pHsensorstring[0])) || !(pHvalue < 14) || !(pHvalue > 0)) {
            getpHdata();
        }
        
        Serial.print("pH: ");
        Serial.println(pHvalue);
        pHsensorstring = "";
        
        delay(100);
        
        getORPdata();
        while(!(isdigit(ORPsensorstring[0])) || !(ORPvalue > -1020) || !(ORPvalue < 1020)){
            getORPdata();
        }
        
        Serial.print("ORP value: ");
        Serial.print(ORPvalue);
        Serial.println(" mV");
        ORPsensorstring = "";
    
        delay(100);
    
        getECdata();
        while(!(isdigit(EC[0])) || !(ECvalue < 50000) || !(ECvalue > 0.07)
            || !(isdigit(TDS[0])) || !(TDSvalue < 10000) || !(TDSvalue > 0.00)
            || !(isdigit(SAL[0])) || !(SALvalue < 100) || !(SALvalue > 0.00)
            || !(isdigit(SG[0])) || !(SGvalue < 1.50) || !(SGvalue > 0.50)) {
    
            ECsensorstring = "";
            getECdata();
        }
    
        Serial.print("Electrical conductivity: ");
        Serial.print(ECvalue);
        Serial.println(" uS/cm");
    
        Serial.print("Total Dissolved Solids: ");
        Serial.print(TDSvalue);
        Serial.println(" mg/L");
    
        Serial.print("Salinity: ");
        Serial.println(SALvalue);
    
        Serial.print("Specific Gravity: ");
        Serial.println(SGvalue, 4);
        Serial.println();
        
        elapsedTime = millis() - startTime;
        Serial.println("Time taken to run program (ms): ");
        Serial.println(elapsedTime);
        
        oldTime = millis();
    }
}

I’m quite a novice at the whole thing, so it’s pretty long. But, it seems to not have any red SOS lights going off for the moment. Any idea what caused yours?

Cheers!

Hey @jeremygilly

Why have you selected to use UART rather the I2C?

I can get 4 sensors working no on I2C but is it a long code.

Cheers,

Mason

Hi there. Creator of Tentacle Shield here. You’re right, it’s a convenience product that gives you 4 isolated channels. It’s like 4 PWR-ISO + 4 BNC connectors.

Regarding the issue of stamps changing back to UART mode - Atlas added a new lock feature to lock the selected bus type. If you have circuits with a recent firmware, this will solve your issue.

Patrick

1 Like

hi!
one reason you can’t get it to work might be the missing voltage on IOREF. We’ve recently published a guide on how to connect the Tentacle Mini to the RPi. Although written for the Raspberry, the principle applies to other host controllers as well:
https://www.whiteboxes.ch/blog/2016/07/how-to-connect-the-tentacle-mini-to-a-raspberry-pi/
Patrick

1 Like

Hey White box labs,

Can you please publish a particle photon code for the tentacle, it will be greatly appreciated.

The I2C version.

Cheers,

Erkele

We’ve just ordered a Photon. Will have a look at it, as soon as I get my hands on it.
Patrick

Btw @erkele, once you’ve connected the Tentacle with 5V, IOREF, GND, SDA, SCL you should be able to use @Gavin 's code as is.

Hey @Whitebox_Labs

Actually Gavins code only contacts one address while if we use 4 different atlas stamps they will need to contact 4 separate addresses.

Are you able to show us an example of lets say, DO, pH, EC, and ORP? I am just interested in how you guys would code that as a standard.

Cheers,

Erkele

Hello,

I just received the mini and am trying to connect it to the Photon
Is this the correct way to wire it?

IOREF to 3.3v from Photon
5V to 5v DC
GND to GND from Photon?
GND for GND from DC
SCL to SCL
SDA to SDA

Hi Ali,

Yes, that looks correct.

I guess the GND from DC is connected to Photons GND anyways, so it should not matter. No harm in just trying :smile:

Patrick

Lol!! I’ll update once I get it running.

I am trying to switch both the sensors to I2C mode. It says to short out PRB with TX. I do not see the color change from green to blue. At power up it flashes blue red. On shorting it does green blue for a sec and then goes to red blue again. Does it blink green for UART and blue for I2C?

Ali,
This should clear things up: https://www.whiteboxes.ch/tentacle/i2c-or-uart/
Note the difference in the procedure for the RTD circuit compared to the others.
Patrick

Yes it did! But on switching the modes it does not breathe cyan it just shows me a solid blue. Switching to UART though blinks green and breathes cyan. Is that normal?

Here’ the way it looks now. I’m using Gavin’s sketch as is. Only showing null. Says no Data