ARC Pro

Upgrade to ARC Pro

Become a Synthiam ARC Pro subscriber to unleash the power of easy and powerful robot programming

PRO
Canada
#1  

It certainly can be hooked up to the EZ-B but you'll need to ensure that the pinout of the sensor matches with the EZ-Bv4 pinout. You may have to modify a cable.

Please see the EZ-Bv4 datasheet for the pinout.

If the wire connections are correct and you have the correct I2C address and code working in ARC, it should work. If it doesn't, you would likely have to mess around with new pull-up resistor values.

PRO
USA
#2  

I did have to modify a cable.  But i am having trouble modifying the arduino code to run in ezscript.  Many functions dont translate well, at least for my limited knowledge of both.  Below is the code if you have any suggestions. /*!

  • @file DFRobot_AS3935_lightning_sensor_ordinary.ino
  • @brief SEN0290 Lightning Sensor
  • @n This sensor can detect lightning and display the distance and intensity of the lightning within 40 km
  • @n It can be set as indoor or outdoor mode.
  • @n The module has three I2C, these addresses are:
  • @n AS3935_ADD1 0x01 A0 = 1 A1 = 0
  • @n AS3935_ADD2 0x02 A0 = 0 A1 = 1
  • @n AS3935_ADD3 0x03 A0 = 1 A1 = 1
  • @copyright Copyright (c) 2010 DFRobot Co.Ltd (http://www.dfrobot.com)
  • @license The MIT License (MIT)
  • @author TangJie
  • @version V1.0.2
  • @date 2019-09-28
  • @url https://github.com/DFRobor/DFRobot_AS3935 */

#include "DFRobot_AS3935_I2C.h"

volatile int8_t AS3935IsrTrig = 0;

#if defined(ESP32) || defined(ESP8266) #define IRQ_PIN 0 #else #define IRQ_PIN 2 #endif

// Antenna tuning capcitance (must be integer multiple of 8, 8 - 120 pf) #define AS3935_CAPACITANCE 96

// Indoor/outdoor mode selection #define AS3935_INDOORS 0 #define AS3935_OUTDOORS 1 #define AS3935_MODE AS3935_INDOORS

// Enable/disable disturber detection #define AS3935_DIST_DIS 0 #define AS3935_DIST_EN 1 #define AS3935_DIST AS3935_DIST_EN

// I2C address #define AS3935_I2C_ADDR AS3935_ADD3

void AS3935_ISR();

DFRobot_AS3935_I2C lightning0((uint8_t)IRQ_PIN, (uint8_t)AS3935_I2C_ADDR);

void setup() {

Serial.begin(115200); Serial.println("DFRobot AS3935 lightning sensor begin!");

while (lightning0.begin() != 0){ Serial.print("."); } lightning0.defInit();

#if defined(ESP32) || defined(ESP8266) attachInterrupt(digitalPinToInterrupt(IRQ_PIN),AS3935_ISR,RISING); #else attachInterrupt(/Interrupt No/0,AS3935_ISR,RISING); #endif

// Configure sensor lightning0.manualCal(AS3935_CAPACITANCE, AS3935_MODE, AS3935_DIST); // Enable interrupt (connect IRQ pin IRQ_PIN: 2, default)

// Connect the IRQ and GND pin to the oscilloscope. // uncomment the following sentences to fine tune the antenna for better performance. // This will dispaly the antenna's resonance frequency/16 on IRQ pin (The resonance frequency will be divided by 16 on this pin) // Tuning AS3935_CAPACITANCE to make the frequency within 500/16 kHz 3.5% // lightning0.setLcoFdiv(0); // lightning0.setIRQOutputSource(3);

}

void loop() { // It does nothing until an interrupt is detected on the IRQ pin. while (AS3935IsrTrig == 0) {delay(1);} delay(5);

// Reset interrupt flag AS3935IsrTrig = 0;

// Get interrupt source uint8_t intSrc = lightning0.getInterruptSrc(); if (intSrc == 1){ // Get rid of non-distance data uint8_t lightningDistKm = lightning0.getLightningDistKm(); Serial.println("Lightning occurs!"); Serial.print("Distance: "); Serial.print(lightningDistKm); Serial.println(" km");

// Get lightning energy intensity
uint32_t lightningEnergyVal = lightning0.getStrikeEnergyRaw();
Serial.print("Intensity: ");
Serial.print(lightningEnergyVal);
Serial.println("");

}else if (intSrc == 2){ Serial.println("Disturber discovered!"); }else if (intSrc == 3){ Serial.println("Noise level too high!"); } } //IRQ handler for AS3935 interrupts void AS3935_ISR() { AS3935IsrTrig = 1; }

PRO
Canada
#3  

You'll have to do some porting of code to translate the I2C code from the Arduino library and example code into EZ-Script or JavaScript for ARC.

I would recommend finding Arduino example code that does not use a library, those examples are the easiest to port.

I have ported a lot of Arduino code to JavaScript for ARC but I cannot offer my services in this case because I rarely have the time and resources to devote to these types of endeavors.

Maybe someone else in the community can help.