
jp15sil24
Here’s my project setup: I have a lawnmower that stays in a small garage. As soon as it moves outside, a camera mounted on the mower should rise using a scissor lift.
The lift should move up when the mower leaves the garage. My idea is to use an EZ-Robot ultrasonic sensor to measure the distance from the side walls:
If the distance is below 40 cm, the camera stays down.
Once the distance is above 40 cm, the camera moves up.
I’m currently testing the ultrasonic sensors, but the results are unreliable. Although they’re powered from 5 V (port D4 on an IoTiny), the readings are inconsistent - sometimes correct, sometimes wrong. I tested five different sensors, and none give stable measurements. I previously used the same sensors on an Arduino without any issue.
So, I tried something else: a Sharp IR sensor. I’m using the ADC Meter Skill and its variable $ADCMeter. Here’s the test script:
// Test IR Sharp Sensor in ARC
// Continually read the global variable $ADCMeter
while (true)
// Get the variable value
var x = getVar("$ADCMeter")
// Print the current ADC value
print("ADC value: " + x)
sleep(1000) // pause for 1 second
endwhile
But I get this error:
Variable not defined: $ADCMeter
It seems the variable isn’t being read from the ADC Meter skill, even though it’s defined there.
Can you tell me what I’m doing wrong? And if you have other ideas for detecting when the mower exits the garage - maybe a better sensor setup than ultrasonic or IR - I’d love your advice.
Thanks,
Below is a detailed explanation and some suggestions to help you resolve the issues with your project.
1. Global Variable Name Mismatch
Your code comments mention that you’re reading the variable "$ADCRead" but then in the script you are calling getVar($ADCMeter). Because global variable names are case-sensitive and must match exactly what you defined in your ADC Meter skill settings, you’ll need to do two things:
Verify the Variable Name in the ADC Meter Skill:
In the ADC Meter skill’s settings in ARC, check the "Variable" field. It will show the exact global variable name (for example, "$ADCRead" or "$ADCMeter") that the skill updates. Use that same name in your script.
Pass the Variable Name as a String:
When you call the getVar() function, always pass the variable name inside quotes. For example, if your ADC Meter skill uses "$ADCRead", modify your script to:
By ensuring the variable name in your script (including proper case and quotes) exactly matches the one defined in your ADC Meter skill, the error "Variable not defined: $ADCMeter" should be resolved.
2. Addressing Unreliable Ultrasonic Sensor Readings
You mentioned that the ultrasonic sensors behave inconsistently, even after testing five sensors and powering them from a 5V digital output on the IoTiny. Here are some troubleshooting tips and alternative ideas:
Power Supply Considerations:
Although your sensors work fine with an Arduino, powering them from a digital pin on the IoTiny may not supply a stable 5V required for consistent operation. Verify that the sensor’s power is coming from a stable 5V source. You may consider powering the sensor from a regulated 5V supply rather than directly from a digital port.
Sensor Mounting and Wiring:
Check that the wiring connections are solid and that the trigger and echo wires are not picking up interference or reflections (especially inside a garage). Sometimes, even slight misalignments or nearby reflective surfaces can cause erratic sensor readings.
Environmental Factors:
Keep in mind that temperature variations or non-ideal sensor placement (such as mounting angle) can introduce inconsistencies. Testing the sensor in the actual environment can help you adjust the sensor orientation.
Consider Other Sensor Options:
If the ultrasonic sensor continues to be unreliable, using an IR sensor (like you started testing with) is one alternative. Other ideas include:
Each alternative has its trade-offs in terms of cost, complexity, and robustness. Since your application involves raising the camera when the mower leaves the garage, ensure the sensor’s detection zone covers the area reliably.
3. Next Steps
Double-check the variable name in your ADC Meter skill and update your script accordingly.
Ensure the ultrasonic sensors have a stable 5V supply. If possible, use a regulated 5V input rather than powering them from an I/O port.
Consider testing with other sensor types (such as LIDAR or photoelectric sensors) if the ultrasonic sensors remain inconsistent.
4. Follow-Up
Feel free to ask if you need additional guidance or have other questions about your ARC project!
Good luck with your project, and I’m here if you need further assistance.
I am a customer support GPT-powered AI and still learning. If you have doubts about my response, please use the support documentation to verify my answer.
i confirm that the skill ADC Meter has the variable $ADCMeter

i spent too much time on ultrasonic with different configurations, external 5v, different regulator, sensor from ez-robot, other brand. i will stay with the sharp ir , it seems i have less surprises till nowI do not believe the IoTiny has a 5V output. The power output pins of all EZ-Robot controllers is VCC (the same voltage as input). So if you are powering the IoTiny with 7.4V LiPo, the D4 power pin would be 7.4V. It would be helpful to verify with the datasheet: https://synthiam.com/Support/Hardware/EZ-B-IoTiny
The ultrasonic sensors do not use ADC. They use digital ports.
The ADC Meter robot skill would not display ultrasonic sensor data. The robot skill for ultrasonic sensors would be the Ultrasonic distance robot skill: https://synthiam.com/Support/Skills/Ultrasonic-Distance/Ultrasonic-Distance?id=16090
While the ultrasonic robot skill is fine to use. It may make more sense not to add the robot skill at all and use the ultrasonic distance read script command. That way, you're saving workspace real estate and, more importantly, CPU processing. https://synthiam.com/Support/javascript-api/Ping/get
Other scripting ultrasonic commands may be helpful for what you're doing. Such as waitForBetween(), waitForHigher(), and waitForLower() etc... You will find those in the manual with the above link from step #4
yes exactly, i use 7.4V lipo for powering the iotiny. on port D4, i use a 5v converter between D4 and the ultrasonic sensor. For the sharp IR,I dont use the port D4, I use the port ADC0. the sharp IR uses a voltage of 4.5v-5v. I take the 5V output( just + and -) from my converter I had used on port D4 for the ultrasonic and i connect the signal output from the sharp sensor to the input ( white socket) of the port ADC0. I have a 5V on the sensor, either ultrasonic or sharp IR. I never used both sensors at the same time, just to be clear. the ultrasonic sensor was connected on port D4. i removed it after some tests and i connected a sharp IR on ADC0 with a power of 5v.
Below is a detailed summary of your setup along with a couple of suggestions you might find useful:
Your Setup Recap
Powering the IoTiny:
You're using a 7.4V LiPo for your IoTiny. The sensor power for both the ultrasonic sensor (during testing) and the Sharp IR sensor is being derived from a 5V converter connected to port D4.
Ultrasonic Sensor:
Sharp IR Sensor:
$ADCMeter
variable) is used to read the sensor value.A Few Suggestions & Considerations
Calibration & Consistency:
Since the Sharp IR sensor gives you an analog voltage proportional to distance, you might need to calibrate or adjust the multiplier setting in the ADC Meter skill. This way, the raw ADC value (normally 0-255) can be converted accurately to your desired unit (such as cm). If you haven’t already, you might want to measure the voltage output at known distances and adjust the multiplier accordingly.
Using Scripting with ADC Input:
To print or process the ADC value from the Sharp IR sensor via script, remember to use the variable name as a string. For example:
This script continuously prints the current ADC reading. Notice the variable name
"$ADCMeter"
is inside quotes.Sensor Choice:
It sounds like you’ve had more stable and predictable results with the Sharp IR sensor, and that may indeed be the best option for your application (raising the camera when leaving the garage). Since the ultrasonic sensor setup was giving you inconsistent results-even after trying different configurations-it makes sense to stick with the IR sensor if it meets your needs.
Additional Sensor Ideas:
While you are currently using the Sharp IR sensor, some other alternatives for detecting when the mower exits the garage include:
Follow-Up Questions
Feel free to ask for further clarification or additional help on any part of your project!
I am a customer support GPT-powered AI and still learning. If you have doubts about my response, please use the support documentation to verify my answer.
yes i modified the multiplier to have some readable values. can you give me an example in javascript of filtering the values coming from the sensor ? i am using the skill ADC value which works fine. As example : if value goes over xxx then then move up with servo-360 in D0) , if the value goes down move down using the servo D0. just need a javascript code, i can adapt the values myself later on.
Below is an example JavaScript snippet that reads the ADC value from your Sharp IR sensor, applies a simple rolling average filter to smooth out fluctuations, and then moves the servo on port D0 up or down based on the filtered reading. You can adjust the thresholds, filter window size, and servo positions as needed:
Code Explanation
Filtering:
A rolling average is implemented by storing the last 5 sensor readings in the array called "filterWindow". Each new reading is added and if there are more than 5 values, the oldest one is removed. The average of these values gives a smoother result.
Thresholds and servo Control:
Using Global Variables:
Note that the script reads the ADC sensor value from the global variable "$ADCMeter". Make sure that your ADC Meter skill is indeed using that exact variable name (including the $ symbol) in its settings.
Customizing:
Adapt the threshold values, servo positions, and the filter window size as needed for your specific setup and desired response.
Feel free to tweak this logic further and let me know if you have any questions or need further adjustments!
I am a customer support GPT-powered AI and still learning. If you have doubts about my response, please use the support documentation to verify my answer.